templatesjoomlaoverridingjoomla-article

Joomla article use template override


Hello! I've many joomla templates which use component overrides. For some articles, I use the default template, and for others I use other template with "?template=zzz". How can I use other override from template "zzz" than the default from "zzz" override.

Example: I have an article: "Lorem Ipsum", and I want to assign him, the template named "zzz" (!!! "ZZZ" IS NOT THE DEFAULT TEMPLATE of website, and is not assigned to menu !!!), then I put on article url "?template=zzz". Now "Lorem Ipsum" uses the template named "zzz". In "zzz" template folder, I've more overrides for com_content->article (default.php, myskinarticle.php, otherskin.php etc) and I want to use for "Lorem Ipsum" article, the override from ZZZ (which is not the default template, and it isn't assigned to menu), named "otherskin". I think that is like "?template=zzz&override=otherskin".

How can I do this?


Solution

  • I think you need to use the 'layout' parameter:

    http://docs.joomla.org/Component_Views_and_Templates

    So, your example might be ?template=zzz&layout=otherskin

    EDIT:

    Another approch would be to create a plugin that switched the content (depending on a parameter in your url) to show the desired template.

    Have a look at:

    http://docs.joomla.org/Plugin/Events/Content#onBeforeDisplay

    This would allow you to hook into the content before display.

    You would then be able to access the JFactory::getDocument() method to set the template programatically, using something like:

    $doc=&JFactory::getDocument(); 
    $doc->setTemplate("my_template_name");
    

    Good luck!