News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Virtuemart 3.0.8 highlighting active (sub) menus - should be a basic feature!

Started by kreativa, May 07, 2015, 12:12:26 PM

Previous topic - Next topic

kreativa

Hi,
I want to add a basic function of active (sub)menu highlighting to Virtuemart 3 menus, but there is no class for active menu to add css style.
Unbelievable that VM is lacking such a basic feature...

I found a solution for older versions https://forum.virtuemart.net/index.php?topic=114722.0 - changing the  modules/mod_virtuemart_category/tmpl/default.php file, but it doesn't work anymore with Virtuemart 3.0.8


Joomla 3.4.1
Virtuemart 3.0.8
PHP 5.4.4-14

Studio 42

Hi
On using layout "All" in the vm category module, the active class is set on active category.
If you need a more advanced category module with more then 2 levels and active class see:
In my shop : http://shop.st42.fr/en/categories-tools/virtuemart-categories-menu.htm
or here : http://extensions.virtuemart.net/categories

Greets,
Patrick

kreativa

Hi, thank you for your answer.
I have 2 levels but I don't want to use a separate module for this.

Studio 42


kreativa

I discovered that the problem on my site was title manager plugin that changed the $title variable

If anybody else needs the solution:

The code that works in all.php (modules/mod_virtuemart_category/tmpl/all.php):
<li <?php echo $active_menu ?>>
    <div>
        <?php echo JHTML::link($caturl, $cattext); ?>
    </div>
<?php if ($category->childs ) {
?>
<ul class="menu<?php echo $class_sfx; ?>">
<?php
    foreach ($category->childs as $child) {
        //BEGIN active checking
        $vm_doc = JFactory::getDocument();
        $vm_title = $vm_doc->getTitle();
        $vm_text = $child->category_name;
        if ($vm_title === $vm_text) {
            $active = "class='active2'";
        }
        else {
            $active = "";
        }
        //END active checking
        $caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$child->virtuemart_category_id);
        $cattext = $child->category_name;
        ?>
<li <?php echo $active; //ADD active class ?>>
    <div ><?php echo JHTML::link($caturl, $cattext); ?></div>
</li>