Skip to main content


function yasglobal_preprocess_page(&$vars, $hook) { if ( isset($vars['node']) ) { // If the node type is "blog" the template suggestion will be "page-blog.tpl.php". if($vars['node']->type == 'story'){ //print $vars['node']->type; exit; $vars['template_files'][] = 'page-story'; } }

Theming a pager for a specific view is possible. For example, if you had a mini pager on a view block called ticker, the theming functions available are:

views_mini_pager__ticker__block_1, views_mini_pager__block_1, views_mini_pager__, views_mini_pager__ticker__block, views_mini_pager__block, views_mini_pager__ticker, views_mini_pager

Then all you need to do is copy the theme_views_mini_pager function into your template.php and change it however you want. For example to only theme the pager on block 1 in my ticker view I would use theme_views_mini_pager__ticker__block_1

If you need to find out all the templates available, put this code on line 85 in within the views/theme/ folder


This will give you an output of all the theming functions the view pager can use.

plz check the full post here

// Helper function used below.
function _menu_subtree_data($item, $tree) {
    foreach ($tree as $cid => $data) {
      if ($item['mlid'] == $data['link']['mlid']) {
        return array($cid => $data);
      if ($data['below']) {
        $return = _menu_subtree_data($item, $data['below'])
        if ($return) {
          return $return;
    return FALSE;
// $mlid is the mlid of the item you wish to have at the root of your menu tree,
// even if you only want its direct children.
$menu_item = menu_link_load(878);
$tree = _menu_subtree_data($menu_item, menu_tree_all_data($menu_item['menu_name']));
// Print out the tree including the parent item
print menu_tree_output($tree);
// Print out the tree, not including the parent item.
$tree = array_shift($tree);
print menu_tree_output($tree['below']);

Step One: Tell Drupal What Template to Use

There are 2 steps you need to take to implement a better looking user registration page within your Drupal site - create a template file, used to display the contents of the form, and make some small changes to template.php within your theme file to tell Drupal which template to use. We will look changes to template.php first, you will be modifying a function called 'themename_theme' (substitute the name of your theme for 'themename' in that statement). If this function is not already there, create it using the example below. Here, we are passing on the name of the template file for the user registration form, and calling it 'user-register'. You can feel free to use any name you wish for the template file.

function themename_theme($existing, $type, $theme, $path) { return array( ... // tell Drupal what template to use for the user register form 'user_register' => array( 'arguments' => array('form' => NULL), 'template' => 'user-register', // this is the name of the template ), ... );

After that is done, reset the registry by clearing cached data at the bottom of the Administer > Performance page.

Step Two: Build Your Template

The next step is you will want to create the template for the user registration form itself. In your theme directory, create a filed called user-register.tpl.php. Notice how the name exactly corresponds to the name we used in the code for template.php. If your form is not displaying properly, there is a good chance it is because there is a mispelling in one of these places. The following example shows you how to create some basic template code that will display the username and password fields, along with the submit button. Within user-register.tpl.php, paste the following code:

<?php print drupal_render($form['account']['name']); // prints the username field
<?php print drupal_render($form['account']['pass']); // print the password field
<?php print drupal_render($form['submit']); // print the submit button print '<div style="display:none">'. drupal_render($form).'</div>';// form id and extra fields if any

At this point, Drupal should know to use your template for generating the user registration page. Season to taste with some CSS and you are on your way to a great looking registration page!

As your site grows more complex, you may need to add additional fields to the form. The drupal_render function tells Drupal to 'build' any field that has been defined for this form. If you ever need to get a list of all the form fields that are part of the user registration form, put the following code anywhere within your template to generate a list of fields that are 'defined' for it.

<?php print '<pre>'; print var_export($form); print '</pre>';

<a href="#" onclick="javascript:window.parent.Lightbox.end();">click here to close lightbox</a>

$("a[rel^=lightframe]").each(function() { $(this).attr("href", $(this).attr("href") + "?format=simple");

There may be instances when you want to show sample XML code on a web page. I'm referring to the raw XML code with any and all markup intact. When the browser believes that the entire page is an XML page (because the page begins with an XML declaration), it will usually do the right thing and display the XML. If, however, you have the XML on an HTML page, the XML markup will be read by the browser instead of displayed.

For example, here is some sample XML data:

<?xml version="1.0" encoding="ISO-8859-1"?>


If you put these lines in an HTML page, they will not display correctly because they look like markup code. Without any modification, they will look like this:

<?xml version="1.0" encoding="ISO-8859-1"?>


The fix is pretty simple. Replace all instances of the open bracket and close bracket with their corresponding HTML character entities, e.g. < and >. After doing so, the HTML should look like the following:

<?xml version="1.0" encoding="ISO-8859-1"?> <text> <to>John</to> <from>Ed</from> <heading>Note</heading> <body>Hello!</body> </text>

When the above HTML is displayed in a browser, the character entities become brackets and the XML data will display correctly. If you do a view source on this web page and look at the first block of XML code above, you will see that it displays correctly because it is using character entities!

When you have a lot of code to display, you may want to use your favorite text editor to search and replace all instances of < and >.

This article is for web-developers who are interested in creating their Drupal themes. It would tell you how to create themes for different content types. As a bonus, you’ll get know how to create theme for an individual page (the default theme will be used for other site pages). Let’s start!
Theme for content type

Usually a few content types are used for Drupal-based site. And every content type should have unique appearance. There is pretty simple solution for this.

Open folder containing the default theme for your site and create the following file there: node-{type}.tpl.php

where {type} – is name of the required content type.

View the folder. You will see node.tpl.php file there. It is the default file which defines the standard appearance of every content type.

Copy content of node.tpl.php to node-{type}.tpl.php and modify it according to your needs. From now, content of the specified content type will appear according to node-{type}.tpl.php.
Theme for page

Sometimes you may need to change theme for some page on your site (for example, http://site/my/page). And other pages should use the default theme.

Open the folder which contains theme for your site and create page-my-page.tpl.php file there. So, name of the created file must consist of page-{next_argument}-{next_argument}.tpl.php.

Than copy content of the default page.tpl.php file to page-my-page.tpl.php and make the desired changes.

Attention! You should use system URL for the page. Make sure that there are no aliases there.