Virtuemart breaking my js sliding submenu’s

Posted on 2010-08-16
Last Modified: 2013-11-11

I am having an issue with a javascript sliding menu. It is for a joomla website using virtuemart.

Please take a look at ... (this keep redirecting back to the live site because of a cookie issue but when that happens just go back to the dev area)

If you use the + and - next to some of the menu items you will see the working effect.

The problem starts when you actually go into the sub menu product pages. Eg.

You will see here that all of the sub menu's are now expanded and will not close.

I can't work out why this is the case. It only breaks when actually within the virtuemart component and it used to work. Its proving to be a real headache for me.

Thanks for reading and hopefully helping me. Cheers

Question by:Snarfles
LVL 13

Expert Comment

ID: 33454868
Try disabling all the vm modules and plugins and see if it wworks

this will work out if its the component

if not slowly activate plugins and modules to locate which one is breaking it

i think it will be one of the modules with the javascript for scrolling products or soemthing like that

javascript conflicts are the most common issue for breaking dropdowns


Author Comment

ID: 33462464
I've narrowed it down a little I think.... kinda

When I disabled the 'RokVirtueMart Product Categories' module ... the menu naturally disappared

When I enabled the default menu 'VirtueMart Product Categories' module ... it kind of works... obviously not how the menu is meant to with the slide though.

One of the interesting things is.... if you open and click on one of the submenu's further down the page... the submenu's above that point do work fine.

Author Comment

ID: 33462483
What I mean by the last paragraph above is that if you go to this link

The current submenu and the bottom submenu dont work but the 2 at the top do.
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

LVL 13

Assisted Solution

StormITSolutions earned 500 total points
ID: 33462549
It looks like  conflict between rok module and your site,
I see what you mean that part of it works and the rest doesnt

i had this issue on a module recently for a menu all menu items worked on the menu except the last which ovelapped another div.

I would report this on the rok forums and see if they have a solution as it seems to be that module causing the issue

LVL 13

Expert Comment

ID: 33462552
Ah actually just had a thought does the module have a limit of levels check that it doesnt and maybe set it to 100 and see if that works


Author Comment

ID: 33462595
In regards to your last comment... I can;t see any level variable... This is the code for building the category tree if that helps...


* @package mod_rokvirtuemart_categories

* @copyright	Copyright (C) 2009 RocketTheme. All rights reserved.

* @license GNU/GPL, see LICENSE.php

* RokVirtuemart Product Categories is free software. This version may have been modified pursuant

* to the GNU General Public License, and as distributed it includes or

* is derivative of works licensed under the GNU General Public License or

* other free or open source software licenses.



defined('_JEXEC') or die('Restricted access');


global $mosConfig_live_site, $mainframe, $current_cat_id;

require_once(CLASSPATH . 'ps_product_category.php');

$uri =& JURI::getInstance($_SERVER['REQUEST_URI']);

$query = $uri->getQuery(true);

$current_cat_id = (count($query) && isset($query['category_id'])) ? intval($query['category_id']) : false;

class RokVMCategoryTree {

	function traverse_tree_down(&$category_html, $category_id = '0', $level = '0', $parent_id = '0') {

		static $ibg = -1;

		global $mosConfig_live_site, $sess, $current_cat_id;

		$db = new ps_DB();


		$query = "SELECT category_name, category_id, category_child_id "

		. "FROM #__{vm}_category as a, #__{vm}_category_xref as b "

		. "WHERE a.category_publish='Y' AND "

		. " b.category_parent_id='$category_id' AND a.category_id=b.category_child_id "

		. "ORDER BY category_parent_id, list_order, category_name ASC";


		while ($db->next_record()) {


			if ($parent_id == 0) {



			else {

				$jj = $parent_id;


			$tree_id = ($ibg == 0) ? 1 : $ibg;

			$item_id = '&Itemid=' . $sess->getShopItemid();

			$category_id = $db->f("category_id", false);

			$category_child_id = $db->f("category_child_id");

			$category_name = $db->f("category_name", false);

			//$link = sefRelToAbs('index.php?option=com_virtuemart&page=shop.browse&category_id=' . $category_id . $item_id . "&TreeId=$tree_id");

			$link = JRoute::_('index.php?option=com_virtuemart&page=shop.browse&category_id=' . $category_id . $item_id . "&TreeId=$tree_id");

			$hasChilds = ps_product_category::has_childs($category_id);

			$active = ($current_cat_id == $category_id) ? ' active ' : '';

			$current = ($current_cat_id == $category_id) ? ' id="current" ' : '';

			$category_html .= "<li " . $current . " class='item " . (($hasChilds) ? 'parent' : '') . $active . "'>";

			//if ($hasChilds) $category_html .= "<div class='arrow arrow-collapse'><span>+</span></div>";

			if ($hasChilds) $category_html .= "<div class='arrow arrow-collapse'></div>";

			//$category_html .= 	"<a id='i_txt0_".$jj."' href='$link'><span class='menuitem'>" . $category_name . "</span></a>";

			$category_html .= 	"<a id='i_txt0_blue' href='$link'><nobr><span class='menuitem'>" . $category_name . "</span></nobr></a>";

			if ($hasChilds) {

				$category_html .= "<ul class='submenu'>";

				$this->traverse_tree_down($category_html, $category_child_id, $level, $jj);

				$category_html .= "</ul>";


			$category_html .= "</li>";





Open in new window


Assisted Solution

Snarfles earned 0 total points
ID: 33462628
wooohoo. some progress!

I commented out the following two lines and it kinda works..

//$active = ($current_cat_id == $category_id) ? ' active ' : '';

                  //$current = ($current_cat_id == $category_id) ? ' id="current" ' : '';

I think it is the $active class that is stuffing it up..

Author Comment

ID: 33463021
So its definitely the active class that is doing it. Current works fine. I commented out the css that related to this section for the active class (which I have listed below) but it didn't make any difference.

So the thing that the active class does is opens up the current submenu to display the whole thing. So its a problem with that, but I'm not sure where to look.
ul.rokvm_categories a span {

	background-position: 15px 11px;

	color: #999999;


ul.rokvm_categories div ul li a span {

	background-position: 15px 11px;



ul.rokvm_categories div ul li a span:hover {



Open in new window

LVL 13

Expert Comment

ID: 33463179
ill have a look when im back from docs


Author Comment

ID: 33471009
Any ideas Storm? :)
LVL 11

Expert Comment

by:Amanda Watson
ID: 33479508
So you have narrowed it down to a problem with the template.
I had exactly the same problem with VM and and rockettheme template.
You could just test to see if another template works for you.  Not an ideal solution but then you could perhaps use their javascript and css if that helps
LVL 13

Expert Comment

ID: 33479573
HI SNarfles,

Forgot to post an update, if you use one of the developer tools for firefox or chrome you can click on the faulty part and see what its called in both the div and css, then go to the rockvm php files in and comment out the references for active

as memory serves me its either in your module folder or the template might have its own custom php files that control the module in that case it will be in the template folder somewhere.

as snowball said test if it works with another template if so then the answer is probably the theme folder.


Accepted Solution

Snarfles earned 0 total points
ID: 33481922
Thanks for your comments. I know where it is setting the active class and have temporarily excluded this, but its not the ultimate solution as when 'active' is not set it doesn't keep the current category expanded and highlight the current subcategory.

Expert Comment

ID: 37143700
I am having the same problem on my site

Snarfles, I followed your advice and changed the following line in helper.php

$category_html .= "<li " . $current . " class='item " . (($hasChilds) ? 'parent' : '') . $active . "'>";

$category_html .= "<li " . $current . " class='item " . (($hasChilds) ? 'parent' : '') .  "'>";

Doesnt seem to help :(

Snarfles do you remember how you fixed it?? I can see it working in

Please help!!



Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Wordpress Pagination Function Not working ? 7 32
JavaScript let vs var 5 27
Hide cell in a table 2 14
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question