How to load preferncies of specified menu item on specified page?

25 views
Skip to first unread message

Mik Urrey

unread,
Mar 22, 2013, 4:06:59 AM3/22/13
to joomla-de...@googlegroups.com
Hi all.
How to load preferncies of specified menu item on specified page, such as modules and template? I try to:

public function onAfterInitialise(){
$app = JFactory::getApplication();
$menu = $app->getMenu('site');
$menu->setActive(131);
}

in system plugin but have no effect.
It is possible to make in component code?

Mik Urrey

unread,
Apr 8, 2013, 9:52:18 AM4/8/13
to joomla-de...@googlegroups.com
This code loads template, template style and modules of specified Itemid:

$Itemid = 171;
//get specified menu item
$app =& JFactory::getApplication();
$menu =& $app->getMenu();
$item = $menu->getItem($Itemid);
//load emplate of this menuitem
$db = JFactory::getDbo();
$db->setQuery('SELECT * FROM #__template_styles WHERE id = '.$item->template_style_id);
$template = $db->loadObject();
$registry = new JRegistry;
$registry->loadJSON($template->params);
$app->setTemplate($template->template, $registry);
//set 'Itemid' variable - it makes system to load attached modules
JRequest::setVar('Itemid', $Itemid);
//it musts to set active item for modules (e.c. mod_menu)
$menu->setActive($Itemid);

why the last line not works? I check executing order, component code loads before any modules. But active item in modules still old.
Reply all
Reply to author
Forward
0 new messages