2

I have a configuration variable which a menu item type where admin can select a menu item. This is used to redirect the front end user if he doesn't have access to the view.

In the component controller file I do the access validation and now I want to redirect to the menu item.

How can I do the redirection to a particular menu item with proper Itemid?

2

I do it this way (providing you know the Itemid)

$app    = JFactory::getApplication();
$menu   = $app->getMenu();

$item           = $menu->getItem($Itemid);
$params         = $item->params;
$return_menu_id = $params->get('return_menu_id ');
$return_item    = $menu->getItem($return_menu_id);  
$return_menu    = JRoute::_($return_item->link.'&Itemid='.$return_item->id);
$app->redirect($return_menu);

Hope this work for you too

2

If you are in controller and have Itemid from component configuration, you can try this simple redirect:

$this->redirect(JRoute::_('index.php?Itemid=' .JComponentHelper::getParams('com_yourcomponent')->get('login_itemid')))

if you have sef it will be used otherwise it will be used a link url from menu item.

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.