How to manually set active menu for nodes


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.