You are hereBlogs / rahul's blog / Add Images/Html in Drupal Node Titles
Add Images/Html in Drupal Node Titles
After some frantic hair-pulling, I finally got this to work in Drupal 6.x. Here I am presenting 2 ways to add images/Html to Drupal node titles (both based on template.php), and you can choose any of them as per your needs. There are pretty other options (including doing this via background-images & css).
- Add these 2 methods to your theme's template.php:
function themename_menu_item_link($link) { if (empty($link['localized_options'])) { $link['localized_options'] = array(); } if(strpos($link['title'], '<img') !== false) { // Allow HTML if the menu description is an image tag: $link['localized_options']['html'] = true; } return l($link['title'], $link['href'], $link['localized_options']); } function phptemplate_get_primary_links() { return menu_tree(variable_get('menu_primary_links_source', 'primary-links')); }Then in page.tpl.php, write this wherever you want to print your primary menu:<?php print phptemplate_get_primary_links(); ?>
You should off-course change the menu names for your desired menu. You would nead to repeat the _get_menu_name() method for each menu you want to support. - Add this single method to your theme's template.php:
function themename_get_primary_links($links) { foreach ($links as &$link) { if(strpos($link['title'], '<img') !== false) { // Allow HTML if the menu description is an image tag: $link['html'] = true; } } return($links); }Then in page.tpl.php, write this wherever you want to print your primary menu:<?php print theme('links', themename_get_primary_links($primary_links), array('class' => 'links primary-links')) ?>You should again change the menu names for your desired menu.
There could be many more variations of these 2 approaches depending upon how you want the menu items to appear, in a list, independently, or whatever.


Post new comment