The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Set Active Menu Item
PostPosted: Fri Aug 31, 2012 10:45 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Jun 25, 2010 8:41 pm
Posts: 7
I am working on creating a custom router for my component. I have the url working just fine. However, the menu isn't. I need to set the active menu item to id 28 so the appropriate menus show up. The line I am using to do this is:

Code:
// Set the active menu item
JSite::getMenu()->setActive(28);


I need to know how to set the active menu item since the above line doesn't get the job done, regardless of where put the line.


Top
 Profile  
 
 Post subject: Re: Set Active Menu Item
PostPosted: Thu Sep 27, 2012 3:08 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Sep 26, 2012 8:39 pm
Posts: 12
I too am trying to set the menu, but so far $menu->setActive($id) has failed.

It must be possible to change the menu by code,

Why is the documentation for joomla so bad?

This is something basic, I have spent hours searching for a solution to something simple as changing the menu, I am able to get the correct Itemid, but am stuck since I am not able to hook the menu to this id.


Top
 Profile  
 
 Post subject: Re: Set Active Menu Item
PostPosted: Thu Sep 27, 2012 5:08 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Sep 26, 2012 8:39 pm
Posts: 12
wizzbangca wrote:
I am working on creating a custom router for my component. I have the url working just fine. However, the menu isn't. I need to set the active menu item to id 28 so the appropriate menus show up. The line I am using to do this is:

Code:
// Set the active menu item
JSite::getMenu()->setActive(28);


I need to know how to set the active menu item since the above line doesn't get the job done, regardless of where put the line.


I was able to get the right menu, but not using JSite::getMenu()->setActive
As as far as I can see - it does nothing

The solution was to add the Itemid to the URL that calls the component being displayed
Per Yngve Berg wrote:
You have to add Itemid=xx, where xx is the id of the menu item on the link that your module produces.
I.e index.php?option=com_mycomponent&view=myview&Itemid=5

Have you created a menu item to your component?

Please see thread - viewtopic.php?f=428&t=757010


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 



Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group