VirtueMart Forum

VirtueMart 2 + 3 + 4 => Frontend Modules => Topic started by: WebStuff on November 27, 2012, 12:35:14 PM

Title: VM Product Category with Joomla Itemid to show in correct module layout.
Post by: WebStuff on November 27, 2012, 12:35:14 PM
I posted this here in case it proves useful to anyone else.

I noticed that the VM2 Product Categories menu "VM - Category" would display the categories without the modules (as in incorrect.jpg attached).
I wanted it to display with the modules (as in correct.jpg attached).
It turned out this was because the module was not using the Joomla Itemid for Virtuemart Categories.

To solve this I first copied [SITE ROOT]/modules/mod_virtuemart_category/tmpl/default.php to [SITE ROOT]/templates/[MY TEMPLATE]/html/mod_virtuemart_category/default.php and set the appropriate permissions.

Opened the copy to edit it.

Below the following code at the top of the file<?php // no direct access
defined('_JEXEC') or die('Restricted access');
//JHTML::stylesheet ( 'menucss.css', 'modules/mod_virtuemart_category/css/', false );


I put in this code://Find VM2 Itemid from Joomla.
$db = &JFactory::getDbo();
$qry = "SELECT `id` FROM #__menu WHERE `link` LIKE \"%com_virtuemart%\" AND `client_id` =0 ";
$db->setQuery($qry);
$db->query();
$modules = $db->loadResult();

$ItemIdString = "";
if ($modules) {
$ItemIdString = "&Itemid=".$modules;
}


Then I changed the following lines: $caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$category->virtuemart_category_id);
$caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$child->virtuemart_category_id);


to be: $caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$category->virtuemart_category_id.$ItemIdString);
$caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$child->virtuemart_category_id.$ItemIdString);


This solved it and now displays the modules correctly.

Loving the template override system.  :)

Hope this helps.





[attachment cleanup by admin]
Title: Re: VM Product Category with Joomla Itemid to show in correct module layout.
Post by: jhoompk on October 03, 2013, 13:49:04 PM
Thank you for this, in new version of VM both following links cant be found at the same place so better to search and replace one by one:

$caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$category->virtuemart_category_id);
and
$caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$child->virtuemart_category_id);