I'm making a custom component in Joomla! 3. Let's call it TestCom (com_testcom).
What I want is to add to items view a simple searching and filtering engines. For this I've created additional, raw view which is responsible for grabbing data from database. Default, html view is sending ajax call to this page during url
Raw view is grabbing the data and sending back to HTML view.
Almost everything is ok, besides one thing. Problem is the url to see details of the item. Normally I'm using
JRoute::_('index.php?option=com_testcom&view=item&id='.$item->id, false, 2)
which will display
In raw view it works, but in html view, when ajax is displaying data it looks like this:
which is not working properly.
What I did is changed a little bit pure url to this:
//get menu item $app = JFactory::getApplication(); $menu = $app->getMenu(); //get component's name $comName = JRequest::getVar('option'); //get actual view's name $viewName = $this->_name; //get menu's item id for our compoent $menuItem = $menu->getItems( 'link', 'index.php?option='.$comName .'&view='.$viewName, true ); echo JRoute::_('index.php?Itemid='.$menuItem->id.'&view=item&id=1',true,2); ?>');
and this will display in both option (raw and html) the same link: