Posted by neeshpal on November 2, 2009 at 8:20pm
Hi All,
I've just started learning theme development and came to know that all of it is developed by drupal variables , html, css and php. I came across list of variables here http://drupal.org/node/11812 , but i think these are not all the variables that are used by drupal. So where can I get more information on all the available variables and how those variables relates to the development from the front end i.e. from the /admin/build/theme page or any other such page.
Thank You.
Comments
_
The available variables depend on what context you're talking about (ie node, page, view, etc) as well as what modules you have installed. The updated version of the page you linked is http://api.drupal.org/api/drupal/modules--system--page.tpl.php (and the corresponding node version is http://api.drupal.org/api/drupal/modules--node--node.tpl.php).
However, since modules and themes can add variables your best bet is to use something like this to see what's available:
<?phpprint '<pre>';
print_r(array_keys(get_defined_vars()))
print '</pre>';
?>
If you use the devel module, you can use
dsm(get_defined_vars());to get a much nicer listing._
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.
Outdated
You're looking at documentation for Drupal 5. Much has changed.
Read the Drupal 6 Theme Developer Guide, any current (D6) book on Drupal theme development, and/or the documentation for any core default template file, such as:
http://api.drupal.org/api/drupal/modules--system--page.tpl.php/6
http://api.drupal.org/api/drupal/modules--node--node.tpl.php/6
etc
Note that different variables are available to different templates.
Many thanks
Thank You all for replying.
Within last 1-2 days since i wrote this post , with the help of above info and the forum info , i've been able to understand the basics of theme development. I created regions with HTML and css for my site. I am struggling in understanding any further like how does the HTML of a menu is produced and how do we customize it for one's specific need. If I am not wrong , it has to do something with hook menu. Any pointers that would help me understand the HTML system of menus will be greatly appreciated.
Thank You again!!
_
http://api.drupal.org/api/function/hook_menu defines menu items and callbacks-- not html.
html is usually taken care of via theming-- either with template files (*.tpl.php) or with theme functions. Menus that appear in blocks are also affected by block.tpl.php files.
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.
Override theme_menu_item how to proceed
Thank You all for pointing me to the right direction . After some search I came across this piece of code to override theme_menu_item and to generate custom ID and classes but I couldnt understand
1.when I put this function in template.php, site gives me an error. I am trying this for zen theme.
"Call to undefined function menu_item_link() in /home/inventi1/public_html/themes/zen/zen/template.php on line 296"
2. how do we use those generated ID's and classes. Do we've to use CSS (our standard style.css file)?
I got it from here:
http://www.nerdliness.com/article/2008/01/01/power-template-php
Can someone please help me with the above.
/**
* Implementation of theme_menu_item().
*
* Add active class and custom id to current menu item links.
*/
function phptemplate_menu_item($mid, $children = '', $leaf = TRUE) {
$item = menu_get_item($mid); // get current menu item
// decide whether to add the active class to this menu item
if ((drupal_get_normal_path($item['path']) == $_GET['q']) // if menu item path...
|| (drupal_is_front_page() && $item['path'] == '<front>')) { // or front page...
$active_class = ' active'; // set active class
} else { // otherwise...
$active_class = ''; // do nothing
}
$attribs = isset($item['description']) ?
array('title' => $item['description']) : array();
$replace = array(' ', '&');
$attribs['id'] = 'menu-'. str_replace($replace, '-', strtolower($item['title']));
return
'<li class="'. ($leaf ? 'leaf' : ($children ? 'expanded' : 'collapsed')) .
$active_class .'" id="'. $attribs['id'] . '">' .
menu_item_link($mid) . $children ."</li>\n";
}
can someone help in the
can someone help in the above? thanks..
did you try google for this
did you try google for this function?
some examples that may be helpful:
http://drupal.org/node/249598
http://19thstreetdesign.com/blog?page=2
http://snipplr.com/view/14034/add-unique-ids-to-drupal-menu-items/
Thanks for
Thanks for links.
(Subscribing)
Some of the example are very useful.
However, I am new to theming. I found that my own version of theme_menu_item is not called. I am using a Zen sub-theme generated by Zenophile.
I presume you are using
I presume you are using Drupal 6 on your site. The function you have is from, and for Drupal 5.
You can see from the api that the function theme_menu_item_link is different:
4.6 – 5 theme_menu_item_link($item, $link_item)
6 theme_menu_item_link($link)
Also in your function you are calling menu_item_link($mid) that does not exist in Drupal 6.
Check this tutorial here on
Check this tutorial here on how to override drupal 6 menus for theming. Here, you get an idea on how to override menu_tree, menu items and menu links.
-- Priyanka, Drupal based product development and theming, US, India