News:

Support the VirtueMart project and become a member

Main Menu

Itemid inheritance problem

Started by esedic, October 01, 2015, 13:11:39 PM

Previous topic - Next topic

esedic

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.

jenkinhill

Is this with the current VM version, 3.0.10?
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

esedic


GJC Web Design

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
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation