VirtueMart Forum

VirtueMart 2 + 3 + 4 => Security (https) / Performance / SEO, SEF, URLs => Topic started by: panoss on March 28, 2017, 19:18:44 PM

Title: Categories' links in the FronPage get Home 's Itemid
Post by: panoss on March 28, 2017, 19:18:44 PM
My Home page, which has menu type = Virtuemart FrontPage, has Itemid=133.
7 categories are listed in the front page, and their links have Itemid=133, which is wrong, this is the home 's Itemid.
Why do they get the home 's Itemid? Should I change some setting?

In file: ...\lioncycles\components\com_virtuemart\sublayouts\categories.php, at line 64:

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

This is where the Itemid is added.
Title: Re: Categories' links in the FronPage get Home 's Itemid
Post by: panoss on March 29, 2017, 12:47:13 PM
This (http://1001sites.eu/lioncycles/index.php?lang=en) is my site, you see 7 photos and above each photo a link.
These are the top categories.

1. Click on the photo of the bikes and you 'll see no Itemid exists in the url.

2. Click 'Home' menu, then click 'Bikes' link again. Now, Itemid exists in the url!!! (but it's the Home Itemid, 133)

How can I fix this?
Title: Re: Categories' links in the FronPage get Home 's Itemid
Post by: panoss on April 08, 2017, 12:50:28 PM
I (kind of) resolved it like this:
(the menuitems belong to a menu named 'mainmenu')

$menutype = 'mainmenu';
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id', 'link')));
$query->from($db->quoteName('#__menu'));
$query->where($db->quoteName('menutype') . ' = ' . $db->quote($menutype));
$query->order('id ASC');
$db->setQuery($query);
$Itemsids_tmp = $db->loadAssocList('id', 'link');


Then from the link, I extract the virtuemart_category_id.
And in the string of the final link ($caturl), I replace the Itemid with the corresponding Itemid that matches with the $virtuemart_category_id.

But this is a query in the subtemplate, which I don't like at all.
Till I find something better,  I 'll have to compromise with this.
Title: Re: Categories' links in the FronPage get Home 's Itemid
Post by: Milbo on April 10, 2017, 08:57:20 AM
The router should do this.
Title: Re: Categories' links in the FronPage get Home 's Itemid
Post by: panoss on April 11, 2017, 13:45:54 PM
Yes, but it doesn't.
Or you mean I should change something it the router's code?