VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: EvanGR on July 29, 2019, 10:41:02 AM

Title: Controlling modules on VM pages
Post by: EvanGR on July 29, 2019, 10:41:02 AM
I need some direction on how to control joomla module visibility on VM pages (e.g. product, category etc..) programmatically. In other words, with template code only, no 3rd party extensions.

Thanks
Title: Re: Controlling modules on VM pages
Post by: StefanSTS on July 29, 2019, 12:09:08 PM
You could place something like this in your product or category layouts.

EDIT: this was used in older Joomla versions, it still works.

$doc = JFactory::getDocument();
$renderer = $doc->loadRenderer('modules');
$position = 'vm-product-bottom';
$options  = array('style' => 'raw');
echo $renderer->render($position, $options, null);


The newer J3 uses:

$modules  = JModuleHelper::getModules("vm-product-bottom");
$doc = JFactory::getDocument();     
$attribs  = array();
$attribs['style'] = 'raw';

foreach ($modules as $mod) {
    echo JModuleHelper::renderModule($mod, $attribs);
}


Add the echo in the place you want the module to appear.

Stefan
Title: Re: Controlling modules on VM pages
Post by: PRO on July 29, 2019, 19:58:54 PM
are you wanting to setup specific modules for single categories? etc?

http://forum.virtuemart.net/index.php?topic=142979.msg505072#msg505072