drupal-7 interview questions
Top drupal-7 frequently asked interview questions
Goal: To send a email with a list of URLs of nodes.
In my custom module I have managed to get the node id which the user wants and I now want to get the URL of each node to put into my email.
I searched the db and used google but I can't seem to find the right solution.
It seems we need to construct the URL something like this:
<?php
global $base_url;
$link=$base_url."// few more parameters
Source: (StackOverflow)
How can I modify or pre-process the <body>
tag to add the class body? I don't want to create a whole html.tpl.php just to add a class.
Source: (StackOverflow)
I'm trying to filter a view to display only nodes of the current user.
Filter by user:current is missing however, where can it be found/enabled?
I must be missing something simple.
Source: (StackOverflow)
I would like to show a node inside another node. So I retrieve the node id of the second node and I would like to render/print/... it inside another node.
But I'm not sure how to do this. I've tried drupal_render
, node_view
, print
,... but with no results. Any advice?
$nid = $node->field_linked_fiche['und'][0]['nid'];
$fullFiche = node_load($nid);
EDIT - the whole template
<?php
/**
* @file
* Bartik's theme implementation to display a single Drupal page.
*
...
*/
?>
<div id="page-wrapper"><div id="page">
<div id="header" class="<?php print $secondary_menu ? 'with-secondary-menu': 'without-secondary-menu'; ?>"><div class="section clearfix">
<?php if ($logo): ?>
<a rel='nofollow' href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
<img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
</a>
<?php endif; ?>
<?php if ($site_name || $site_slogan): ?>
<div id="name-and-slogan"<?php if ($hide_site_name && $hide_site_slogan) { print ' class="element-invisible"'; } ?>>
<?php if ($site_name): ?>
<?php if ($title): ?>
<div id="site-name"<?php if ($hide_site_name) { print ' class="element-invisible"'; } ?>>
<strong>
<a rel='nofollow' href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
</strong>
</div>
<?php else: /* Use h1 when the content title is empty */ ?>
<h1 id="site-name"<?php if ($hide_site_name) { print ' class="element-invisible"'; } ?>>
<a rel='nofollow' href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
</h1>
<?php endif; ?>
<?php endif; ?>
<?php if ($site_slogan): ?>
<div id="site-slogan"<?php if ($hide_site_slogan) { print ' class="element-invisible"'; } ?>>
<?php print $site_slogan; ?>
</div>
<?php endif; ?>
</div> <!-- /#name-and-slogan -->
<?php endif; ?>
<?php print render($page['header']); ?>
<?php if ($main_menu): ?>
<div id="main-menu" class="navigation">
<?php print theme('links__system_main_menu', array(
'links' => $main_menu,
'attributes' => array(
'id' => 'main-menu-links',
'class' => array('links', 'clearfix'),
),
'heading' => array(
'text' => t('Main menu'),
'level' => 'h2',
'class' => array('element-invisible'),
),
)); ?>
</div> <!-- /#main-menu -->
<?php endif; ?>
<?php if ($secondary_menu): ?>
<div id="secondary-menu" class="navigation">
<?php print theme('links__system_secondary_menu', array(
'links' => $secondary_menu,
'attributes' => array(
'id' => 'secondary-menu-links',
'class' => array('links', 'inline', 'clearfix'),
),
'heading' => array(
'text' => t('Secondary menu'),
'level' => 'h2',
'class' => array('element-invisible'),
),
)); ?>
</div> <!-- /#secondary-menu -->
<?php endif; ?>
</div></div> <!-- /.section, /#header -->
<?php if ($messages): ?>
<div id="messages"><div class="section clearfix">
<?php print $messages; ?>
</div></div> <!-- /.section, /#messages -->
<?php endif; ?>
<div id="main-wrapper" class="clearfix"><div id="main" class="clearfix">
<?php if ($breadcrumb): ?>
<div id="breadcrumb"><?php print $breadcrumb; ?></div>
<?php endif; ?>
<?php if ($page['sidebar_first']): ?>
<div id="sidebar-first" class="column sidebar"><div class="section">
<?php print render($page['sidebar_first']); ?>
</div></div> <!-- /.section, /#sidebar-first -->
<?php endif; ?>
<div id="content" class="column"><div class="section">
<?php if ($page['highlighted']): ?><div id="highlighted"><?php print render($page['highlighted']); ?></div><?php endif; ?>
<a id="main-content"></a>
<?php print render($title_prefix); ?>
<?php if ($title): ?>
<h1 class="title" id="page-title">
<?php print $title; ?>
</h1>
<?php endif; ?>
<?php print render($title_suffix); ?>
<?php if ($tabs): ?>
<div class="tabs">
<?php print render($tabs); ?>
</div>
<?php endif; ?>
<?php print render($page['help']); ?>
<?php if ($action_links): ?>
<ul class="action-links">
<?php print render($action_links); ?>
</ul>
<?php endif; ?>
// Render second node inside this one
<?php
$nid = 739; // NOTE :: Hard coded, but need to be variable!!
drupal_render(node_view(node_load($nid)))
?>
<?php print render($page['content']); ?>
<?php print $feed_icons; ?>
</div></div> <!-- /.section, /#content -->
<?php if ($page['sidebar_second']): ?>
<div id="sidebar-second" class="column sidebar"><div class="section">
<?php print render($page['sidebar_second']); ?>
</div></div> <!-- /.section, /#sidebar-second -->
<?php endif; ?>
</div></div> <!-- /#main, /#main-wrapper -->
<div id="footer-wrapper"><div class="section">
<?php if ($page['footer']): ?>
<div id="footer" class="clearfix">
<?php print render($page['footer']); ?>
</div> <!-- /#footer -->
<?php endif; ?>
</div></div> <!-- /.section, /#footer-wrapper -->
</div></div> <!-- /#page, /#page-wrapper -->
Source: (StackOverflow)
We were working with Drupal 7 and trying to rewrite the views output
We need the src of the image field , not the whole image tag.
Clicking on
Rewrite the output of this field
[field_first_image]
: Gives the whole content ie with tag ,
We tried to display the below ones
[field_first_image-fid]
== Raw fid
[field_first_image-alt]
== Raw alt
[field_first_image-title]
== Raw title
But the same ( [field_first_image-fid] ) thing is displayed in the view. Is there a way we can get the src from the views rewrite ?
Source: (StackOverflow)
In Drupal 6, it was easy to insert a block into a template with the following code:
$block = module_invoke('views', 'block', 'view', 'block_name');
print $block['content'];
However, using the same instructions in Drupal 7 does not seem to work. I have looked around and cannot find the new method.
Does Drupal 7 have a routine that can allow for pro grammatically inserting a block into a template or node?
Source: (StackOverflow)
What is the difference between
function mythemes_preprocess_html(&$variables) { ... }
and
function mythemes_process_html(&$variables) { ... }
in drupal 7 template.php.
when must use preprocess functions and when must use process functions.
thanks.
Source: (StackOverflow)
How to get the currently logged in user's role in Drupal 7 ? Do you know a simple way of accomplish this ? Is there some drupal core functions for this?
Source: (StackOverflow)
Could someone provide a architectural overview of the Drupal 7 control flow? Perhaps in the sense of a flowchart about how a page gets generated. What additional resources would you suggest consulting with regards to how Drupal works?
Source: (StackOverflow)
OK, I finally figured out how to add (or edit) form controls through the form API
in Drupal.
But now, I would like to add text to a form. Not a <textarea>
, and not a <textfield>
; both of which can be edited by the user. I would like to add <p>static text</p>
, written by me, to be read by the user.
How would one do that?
Source: (StackOverflow)
After having just registered a new account and created a profile how would I log a user in?
I have tried :
global $user;
$user = user_load($account->uid);
or
global $user;
$user = user_load(array('mail' => $_POST['email'], 'pass' => trim($_POST['password'])));
but neither work and the second results in an error about array_flip.
Source: (StackOverflow)
Is there a way to export a content type from a site and import it to another? I haven't found any modules to do that yet.
How would you achieve that? It's a useful thing to be done otherwise it is very time consuming to create the same content type over and over again.
Source: (StackOverflow)
I am working on Drupal. I want to know how to change that footer text Powered by Drupal and link given to it. I want there "Copyrights 2012 (My site name).All Rights reserved." I can not getting it can any one help me.
Source: (StackOverflow)