VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: JLinker on July 17, 2015, 14:05:22 PM

Title: Joomla setTemplate() function not working with virtuemart
Post by: JLinker on July 17, 2015, 14:05:22 PM
Hi everyone,

I use this code in a Joomla system plugin, in order to change the default Joomla template on the fly:

$app = JFactory::getApplication();
$app->setTemplate('mytemplate');


I works on all joomla and 3rd party extensions, but not on virtuemart pages.
Any idea why?
Thanks a lot
Title: Re: Joomla setTemplate() function not working with virtuemart
Post by: JLinker on July 17, 2015, 14:26:03 PM
I can see in the vm configuration that there is a setting defining the Joomla template vm should use.
So, vm probably ignores the code above and sticks to the template set in the vm config.

I'm building a mobile template for my shop. Using the code above, I've managed to change the Joomla template to use if the device trying to connect to the site is a mobile.

So the question is: how do I ask virtuemart to use a specific template for a client, using php?
Title: Re: Joomla setTemplate() function not working with virtuemart
Post by: JLinker on July 18, 2015, 01:23:50 AM
The answer is:
setTemplate() will work only if the vm config says "use default Joomla template" for the template parameter.
if this parameter is set to something else, virtuemart will ignore the setTemplate() function.
Title: Re: Joomla setTemplate() function not working with virtuemart
Post by: Milbo on July 21, 2015, 12:23:15 PM
no, vm does not ignore it. and you are going to write programs?

Vm just calls the setTemplate function LATER ! that is all. Btw the function setTemplate does not correctly work for styles.