1

I' am trying to make a custom module to set an active trail path to a menu. I created a views page. The active trail must be to a node or taxonmy term. When I open the pages created by the view the active trail is not active.

I wrote the script here below but it doesn't work, can somebody please help???

function mymodule_views_default_views(&$view, &$display_id, &$args){
  if( $view->name = 'productdetail';)
    {menu_tree_set_path('menu-categorie', 'node/39');
 }
}
  • what is menu name? – monymirza Mar 4 '13 at 8:18
  • menu-categorie is the menu name. I have although found a solution, will post it this afternoon. – Christiane Peschen Mar 4 '13 at 12:18
  • Can you explain the question a little better? (so others can benefit, and/or we might have even better answers) What kind of View is it? What is the URL of the view? Does it have arguments? What role do the arguments play for the menu trail? What do you expect by "set an active trail path to a menu" ? – donquixote Nov 8 '13 at 2:31
0

I found the answer to my own question.

In the view I added a field with the taxonomy term ID / node ID which is although used for my menu and hide the output and do a rewrite of the output. I pasted the following code in the text field for rewrite; field_categorie-tid is my reference term from the menu.

menu_tree_set_path('menu-categorie', 'taxonomy/term/[field_categorie-tid]');

Instead of taxonomy/term/[field_categorie-tid] you can also use node/[nid].

I added in the head section a global field with PHP and token, and put <?php [field_categorie]?>.

That's all; no hooks nor custom scripting in the template.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.