1

Virtuemart 3.0.4 Joomla 3.3.6.

I am trying to figure out what's the way to setup the following in virtuemart.

I have the Main store's view with a menu item of type : VM Category Layout. It is set to show all categories with top level category the root category.

The page displays all categories. Now, clicking on a category, I want to open that Category's Browse Products view.

But this is not happening.


Clue 1:
The problem is that both the above views are controlled by the same menu item. And this menu item, has an option called "Page Layout", with options: Categories, or Default.

Categories will display child categories of a parent category, while Default will display products from a category.

On my menu item I have this set to categories, in order to display all categories.


Clue 2:
All categories without a menu item dedicated to them, if clicked from that view, will open under that same itemid. However the view seems to inherits its page layout setting from that menu item (set to display categories) and won't display the products browse view of a selected category.



I would like to avoid creating menu items for each category, as it would make it easier for the store owner to change the categories and those they will automatically be updated in the front-end, without touching menu items at all.

I am thinking to create overrides to deal with this, but first I would like to ensure that I am not missing anything obvious.

Have you ever come across this situation with VM ? Or is it possible that this is a "silly" setting somewhere ?

2

Actually, following the override idea, is pretty simple - and I can't understand why the VM developers have left this as it is now.

In the Categories template file of the Category Layout view:

(components/com_virtuemart/views/category/tmpl/categories.php)  

all is needed to create a continuity in the browsing workflow, is to add a line of code like:

else { include ('template') } 

Currently the categories template, checks if a category has other children categories and if yes, it will load them. But there is nothing for the case that the category has no children categories.

So, in the categories override template file, we can continue the if statement with an else, and include the default template, to display category's products, if the category has no more children categories.

The template will become like this:

if ($this->category->haschildren) {

    // Calculating Categories Per Row
    //$categories_per_row = VmConfig::get ( 'categories_per_row', 3 );

    // Start the Output
    echo ShopFunctionsF::renderVmSubLayout('categories',array('categories'=> $this->category->children));

} 

 // Add these lines to include the default template.
else {
    include('default.php');
}

Make sure you will copy both files inside the overrides folder of your template.

Finally, adjust the settings of the Menu Item, to show products with your desired products layout.

  • Where is the category file for editing it? – Antonio Mar 17 '15 at 17:45
  • The template files of above the above answer are in: components/com_virtuemart/views/category/tmpl/ – FFrewin Mar 17 '15 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.