I need to be able to get a menu item based on the Itemid, then temporarily override one of the values used in the query string in the PHP, and finally generate the link that Joomla would then use. I do NOT want to change the actual menu item, or have alternate menu items, etc.
The actual requirement is a bit complicated, so for the sake of simplicity, let's say that I need to use article ID #1 during the day, and article ID#2 after 6:00PM.
So,the actually menu item is: option=com_content&view=article&id=1&Itemid=100
If it's after 6:00PM, I need something like $menu->getItem($itemid)->link
to return option=com_content&view=article&id=2&Itemid=100
instead.
I've been trying this with $app->getMenu();
and new JMenu
, but am obviously missing something. I would imagine the code would be something like this:
$menu = $app->getMenu();
$menuitem = $menu->getItem(100);
$menu->setProperties('the_article_id',2);
$templink = $menuitem->link;
// $templink should be: option=com_content&view=article&id=2&Itemid=100
...continue my processing with $templink
To clarify, the highly specialized actual requirement is essentially generating a series of links based on existing menu items, who they are, and where they are on the site, thus using JInput and/or redirecting is not an option. Getting and manipulating the menu object is necessary to come up with the various links I need to display (not actually going to them, unless the user clicks on one which has been displayed to them).