Posted By

electblake on 04/14/10


Tagged

menu path drupal 6x hooknodeapi activemenu


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

jmaties
phpdiva
Onfire60


How to manually set active menu for nodes


 / Published in: PHP
 

initial code and concept bitten from: http://drupal.org/project/menutrails

  1. /**
  2.  * Implementation of hook_nodeapi().
  3.  *
  4.  * This will evaluate individual nodes when being viewed and take the necessary
  5.  * steps to set the active_trail for menus.
  6.  *
  7.  * This will retain menu state at the node/view level. For instance, forum nodes
  8.  * would maintain an active trail to the forum menu item.
  9.  */
  10. function hook_nodeapi(&$node, $op, $a3 = NULL, $page = FALSE) {
  11. if ($op == 'view' && $page == TRUE && $node->type == 'your-type') {
  12.  
  13. // IF YOU HAVE ALIAS AND NOT INTERNAL PATH
  14. /// $path = drupal_lookup_path('source',$url);
  15. $item = menu_get_item('internal-drupal-path');
  16. if ($item) {
  17. menu_set_item(null, $item);
  18. }
  19. }
  20. }

Report this snippet  

You need to login to post a comment.