4

I'm trying to link to a content article and force a specific layout override to be used in the display, however I'm having some troubles. I've tried the following:

JRoute::_("index.php?option=com_content&view=article&id={$this->item->id}&layout=mylayout&catid={$this->item->catid}");

and

JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid).'&layout=mylayout'); 

however, none of them seem to get me closer to heaven, only my default override (default.php) is used, not mylayout.php. I've also tried adding an Itemid to a menu item linked to a test-content-item with this layout. The test displays with the correct layout, but not the link with the added Itemid.

I also tried including the template-name in the layout-parameter ( layout=mytemplate:mylayout ) but still no luck.

Any idea how to make a link that displays an item with the specified layout? The joomla version is 3.3.0.

1

First of all, make sure that you have placed yourlayout.php file into the right directory and that Joomla can load it. Then you should assign that layout to the article/s you want them make use of it.

Note that if the article is linked to a menu item, then the alternative layout will not work. In this case you have to create also a yourlayout.xml file matching your layout php file, and place it next to it.

Then you will have to change the menu item used for this article with your new menu-item.

  • OK, so there is no way to override the layout selected in the article by useing GET-parameters? – jonasfh May 22 '14 at 15:20
  • Well you could try to achieve that in the article view controller (display method)... I don't know if you can access GET data there, but you could try to get it and then set the layout accordingly... Can't test right now, though. – elk Jun 1 '14 at 11:48

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.