So I'm working on my a new component and I want to be able to route to a menu item when access is denied for a certain action.
I created a menu_id field in my table and I'm using the menuitem form field type to store the menu itemId.
I thought that I would be able to use the controllers setRedirect function like so
if($isRestricted && !$canDownload)
{
$msg = $this->translate('COM_BABELU_PRODUCTS_DL_NOT_AUTHORISED');
$this->setRedirect('index.php?itemId=101', $msg, 'warning');
return false;
}
However it didn't work. it just appended the item id to the route
http://mysite.com/previous-menu-item-alias?itemId=101
This didn't even load the view associated with the menu item with the ID 101.
Do I need to specify the entire route? I.E. lookup the link from the #__menus table and then call JRoute with that value?
If anyone has exp with this I would really appreciate any information.
----Edit --- I've done this before by querying the #__menus table directly and getting the link value then pushing that into JRoute. However I don't like the idea of querying the table directly because it creates a direct dependency. What I really want to know is how to get the link value without touching the #__menus table, or if there is a way to direct to a menu item using only the itemId.