We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

wesbaker on 06/24/08


Tagged

css menu textmate drupal id


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

basicmagic


CSS IDs for Menu and Slicemenu Items


Published in: PHP 


  1. function phptemplate_menu_item($mid, $children = '', $leaf = TRUE) {
  2. $class = ($leaf ? 'leaf' : ($children ? 'expanded' : 'collapsed'));
  3. $id = 'li-'.str_replace(array(' ','!','&','.','?','/'),array('-','','and','','','-'), strtolower(strip_tags(menu_item_link($mid))));
  4. return '<li id="'.$id.'" class="'. $class .'">'. menu_item_link($mid) . $children ."</li>\n";
  5. }
  6.  
  7. function phptemplate_slicedmenu_item($mid, $trail) {
  8. $class = (in_array($mid, $trail) ? 'active' : 'inactive');
  9. $id = 'li-'.str_replace(array(' ','!','&amp;','.','?','/'),array('-','','and','','','-'), strtolower(strip_tags(menu_item_link($mid))));
  10. return '<li id="'.$id.'" class="'. $class .'">'. menu_item_link($mid) ."</li>\n";
  11. }
  12.  
  13. function phptemplate_menu_item_link($item, $link_item) {
  14. return l('<span class="menu-text">'.htmlentities($item['title']).'</span>', $link_item['path'], !empty($item['description']) ? array('title' => $item['description']) : array(), isset($item['query']) ? $item['query'] : NULL, null, false, true);
  15. }

Report this snippet 

You need to login to post a comment.