VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: esedic on October 01, 2015, 13:11:39 PM

Title: Itemid inheritance problem
Post by: esedic on October 01, 2015, 13:11:39 PM
Hi!

I have a VM category structure, first level categories have child categories (up to 4 levels deep) like this:
-category 1 (first level category)
--category 2 (child of category 1)
---category 3 (child of category 2)
----category 4 (child of category 3)
-----category 5 (child of category 4)

Then I have a main menu with VM category links, where I have set up parameters to show only categories without products ("Show categories" = Yes, "Show products" = No), except for last level category (in my case category 5), which displays only products ("Show categories" = No (this one is irrelevant since last level category don't have child categories), "Show products" = Yes).

So if I browse through categories through main menu links, everything is ok.

The problem occurs in three scenarios:
-if I have a VM frontpage menu link
-if I have a VM Category link (with Top level Category in Select a category dropdown)
-if I have a static HTML page with first level categories with links, which are copied from mainmenu

In all the scenarios Itemid in child category is inherited from link on parent category, which is normal behaviour.
The problem is, when I get to last level category, products are not displayed since VM gets menu parameters based on Itemid. And Itemid from parent category has parameter Show products set No.

I tried to override category default view and to play with variables like $this->showproducts, but I got errors thrown all the time.
Then I saw that in view.html.php some of the data from model (sort, pagination, rating, etc) is rendered only if $this ->showproducts is set.

Is there a nice way to solve this?
I'm currently out of ideas.
Title: Re: Itemid inheritance problem
Post by: jenkinhill on October 01, 2015, 14:49:47 PM
Is this with the current VM version, 3.0.10?
Title: Re: Itemid inheritance problem
Post by: esedic on October 01, 2015, 14:53:21 PM
Yes, VM 3.0.10 and Joomla 3.4.4
Title: Re: Itemid inheritance problem
Post by: GJC Web Design on October 01, 2015, 15:41:46 PM
Yes - can confirm this behaviour from an earlier project

I think I did a sublayout over ride for the " 2nd last" cat levels and
changed the cat link to

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

I see this also..

$caturl = str_replace('&Itemid=352','',$caturl);

maybe this was to get rid of the top level itemid ...  must start commenting my code..  ;)

was a while ago but this may help