VirtueMart Forum

VirtueMart 2 + 3 + 4 => Frontend Modules => Topic started by: BjornOnPole on April 11, 2013, 16:27:17 PM

Title: How to highlight active submenu item from Module VirtueMart Category?
Post by: BjornOnPole on April 11, 2013, 16:27:17 PM
Hello,

I have a website where the Module Virtuemart Category is being used to display a category menu.

The website is behind a password which I cannot really share, so here is a screenshot: http://i.imgur.com/3iZ4tyz.png

As you can see this is the page 'Starterkits', which is in the submenu of the module.

I want to be able to highlight this menu item, but it does not seem to have a 'active' class, or something like that (see Firebug). And without that class I cannot add CSS to it.

Could anyone please tell me how I could highlight the active submenu item when using Module VirtueMart Category?

Thanks in advance!
Title: Re: How to highlight active submenu item from Module VirtueMart Category?
Post by: BjornOnPole on April 15, 2013, 14:10:28 PM
Seems to me this should be a normal feature. Doesn't anyone know?
Title: Re: How to highlight active submenu item from Module VirtueMart Category?
Post by: balai on April 15, 2013, 18:10:07 PM
Is this the default VM category module?

I think that if is, there should be a template override of the module's output which is responsible for that
Title: Re: How to highlight active submenu item from Module VirtueMart Category?
Post by: BjornOnPole on April 16, 2013, 16:15:13 PM
Quote from: balai on April 15, 2013, 18:10:07 PM
Is this the default VM category module?

I think that if is, there should be a template override of the module's output which is responsible for that

Thanks for your reply!

Yes, it is the default VM category module.

Are you saying the template I am using causes this problem? Or that I have to create a template override to fix this problem?

The owner has removed the default Joomla templates, so it's hard for me to test.
Title: Re: How to highlight active submenu item from Module VirtueMart Category?
Post by: BjornOnPole on April 22, 2013, 14:05:39 PM
I have just tested by uploading a new template.

When I click on a menu item then, I get the error 500 "Default not found".

So obviously more things are wrong. Anyone know a trick how I can add this active class myself?
Title: Re: How to highlight active submenu item from Module VirtueMart Category?
Post by: balai on April 22, 2013, 18:29:18 PM
Hi

Open the categories module you are using and check the layout which is selected.
Change that and check if it works
Title: Re: How to highlight active submenu item from Module VirtueMart Category?
Post by: BjornOnPole on April 24, 2013, 09:54:55 AM
Thanks for your reply! It did not work when I changed the templates, but it pointed me in the right direction.

For anyone with the same problem:

I added the following code to modules/mod_virtuemart_category/tmpl/default.php:

<?php
$mydoc JFactory::getDocument();
$mytitle $mydoc->getTitle();
if ($mytitle === $cattext) {
$active "class='active'";
}
else {
$active "";
}
?>


And then added that class to the links:

<?php echo JHTML::link($caturl$cattext$active); ?></div>

And then it worked!

Ofcourse, don't forget to make this a template override or your changes will be gone in the next update.
And you still need to style this yourself, ofcourse.

Thanks for your help!