VirtueMart Forum

VirtueMart 2 + 3 + 4 => Frontend Modules => Topic started by: janis on January 22, 2012, 17:36:50 PM

Title: module VM - Category only shows 2nodes not the 3de one.
Post by: janis on January 22, 2012, 17:36:50 PM
hi

why i only see 2node's?

(http://img685.imageshack.us/img685/5840/12812665.jpg) (http://imageshack.us/photo/my-images/685/12812665.jpg/)

Uploaded with ImageShack.us (http://imageshack.us)
Title: Re: module VM - Category only shows 2nodes not the 3de one.
Post by: PRO on January 22, 2012, 19:27:06 PM
the module is only a 2 level module.

Title: Re: module VM - Category only shows 2nodes not the 3de one.
Post by: janis on January 22, 2012, 19:44:43 PM
hi

this is really bad..

uuu... what can i do to have more levels?? maybe other ways?

because i really need more levels..


gr.
Title: Re: module VM - Category only shows 2nodes not the 3de one.
Post by: PRO on January 23, 2012, 02:38:15 AM
janis, if you have 1000 categories, or 50, 000 categories. THE page would be soooo slow. So, thats why its not in the core.

I'm sure there will be 0a 3rd party module developed.

YOPU can always use thje joomla menu system, and make your own
Title: Re: module VM - Category only shows 2nodes not the 3de one.
Post by: patrickit on February 06, 2012, 05:37:46 AM
Hi,

@BanquetTables.pro - using the joomla menu system - wouldn't that be fixed? What if we add new categories/sub categories to it?

@Janis There is a module but it didn't work in my vm2.0, if you have an earlier version of vm it may work - http://extensions.joomla.org/extensions/extension-specific/virtuemart-extensions/virtuemart-categories/9902 (http://extensions.joomla.org/extensions/extension-specific/virtuemart-extensions/virtuemart-categories/9902)

If it doesn't, and since there are no modules then I have a temporary workaround hack for you. Note that my workaround goes 1 extra level deep (3rd node), you can customize it for more nodes if required.
You can see a working demo here http://x-doria.ae/ (http://x-doria.ae/)
Hope it helps!

go to modules/mod_virtuemart_category/mod_virtuemart_category.php
find  (around line 46)
foreach ($categories as $category) {

      $category->childs = $cache->call( array( 'VirtueMartModelCategory', 'getChildCategoryList' ),$vendorId, $category->virtuemart_category_id );
add after it
//PL temp hack show 3rd node
      if($category->childs){
         foreach($category->childs as $child){
            $child->childs = $cache->call( array( 'VirtueMartModelCategory', 'getChildCategoryList' ),$vendorId, $child->virtuemart_category_id );
         }
      }
      //PL end

go to modules/mod_virtuemart_category/tmpl/all.php
find  (around line 32)
<div ><?php echo JHTML::link($caturl, $cattext); ?></div>

add after it
<?php if ($child->childs ) {   //PL temp hack show 3rd node
   ?>
      <ul class="menu<?php echo $class_sfx; ?>">
      <?php
         foreach ($child->childs as $grandchild) {      
            $caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$grandchild->virtuemart_category_id);
            $cattext = $grandchild->category_name;
            ?>
      <li>
         <div ><?php echo JHTML::link($caturl, $cattext); ?></div>
      </li>
      <?php } ?>
      </ul>
   <?php    } //PL end ?>
Title: Re: module VM - Category only shows 2nodes not the 3de one.
Post by: alex_corba on February 10, 2012, 15:40:31 PM
Thank you for that great workaround hack! But I have still a little problem with it: I don't want to display all the categories, 1 level subcategories and 2nd level subcategories at once (i have too much subcategories!). I prefer using the accordion effect or only the current category effect, so when I click on a category only the subcategories of the parent category is shown and when I click on a subcategory first level the subcategory 2nd level is shown. Here is the link: http://cmss.planetmuscle.de/ (http://cmss.planetmuscle.de/)

I submit the hack in modules/mod_virtuemart_category/tmpl/current.php but the subcategories are shown at once.
Can you help me how to fix it?
Title: Re: module VM - Category only shows 2nodes not the 3de one.
Post by: patrickit on February 12, 2012, 08:03:57 AM
Alex,

That can be set in the css/javascript. You can hide what you don't need and display them on click.
Title: Re: module VM - Category only shows 2nodes not the 3de one.
Post by: wnrdesign on June 04, 2012, 20:15:30 PM
I'm having the same problem! Hack works but after dropdown all subcategories are shown.

Any updates on thisone?
Title: Re: module VM - Category only shows 2nodes not the 3de one.
Post by: mysmx on June 10, 2012, 02:29:50 AM
just change to this: (i added f($child->virtuemart_category_id==$active_category_id))

if($category->childs){      
      foreach($category->childs as $child){      
         if($child->virtuemart_category_id==$active_category_id){      
           $child->childs = $cache->call( array( 'VirtueMartModelCategory', 'getChildCategoryList' ),$vendorId, $child->virtuemart_category_id );         
          }
         }
      }
Title: Re: module VM - Category only shows 2nodes not the 3de one.
Post by: alexdixondesign on June 17, 2012, 15:03:28 PM
I simply added the hack as above, and then inserted the second snippet of code into "current.php" (as below).

This seems to only expand any sub categories under the active parent without expanding the whole store. It also worked in "default.php".


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

<?php if ($child->childs ) {   //PL temp hack show 3rd node
   
?>

      <ul class="menu<?php echo $class_sfx?>">
      <?php
         
foreach ($child->childs as $grandchild) {      
            
$caturl JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$grandchild->virtuemart_category_id);
            
$cattext $grandchild->category_name;
            
?>

      <li>
         <div ><?php echo JHTML::link($caturl$cattext); ?></div>
      </li>
      <?php ?>
      </ul>
   <?php    //PL end ?>

</li>
Title: Re: module VM - Category only shows 2nodes not the 3de one.
Post by: hothotheat on July 02, 2012, 16:11:17 PM
Thanks for this hack!

It all works fine, there is just one small bug:
When I click on a 2nd node the sub-categories of the 3rd node are shown correct. But when I click on a 3rd node, this 3rd node categories are gone after page loaded. I couldn't find a solution, any ideas?

I tested it with the default and the current template, both the same bug.
Title: Re: module VM - Category only shows 2nodes not the 3de one.
Post by: nerfmarius on February 05, 2013, 10:01:49 AM
Quote from: hothotheat on July 02, 2012, 16:11:17 PM
Thanks for this hack!

It all works fine, there is just one small bug:
When I click on a 2nd node the sub-categories of the 3rd node are shown correct. But when I click on a 3rd node, this 3rd node categories are gone after page loaded. I couldn't find a solution, any ideas?

I tested it with the default and the current template, both the same bug.

Same here, did anyone find a solution to this?
Title: Re: module VM - Category only shows 2nodes not the 3de one.
Post by: priyank2512 on February 08, 2013, 07:48:33 AM
hello,
i am new in virtuemart,
can you please tell me that how to add 4th node in this module?
thank you
Title: Re: module VM - Category only shows 2nodes not the 3de one.
Post by: jjk on February 08, 2013, 09:03:32 AM
You might try one of the available third party modules. Links:
http://forum.virtuemart.net/index.php?topic=97122.0 (http://forum.virtuemart.net/index.php?topic=97122.0)
http://extensions.joomla.org/extensions/extension-specific/virtuemart-extensions/virtuemart-navigation (http://extensions.joomla.org/extensions/extension-specific/virtuemart-extensions/virtuemart-navigation)
Title: Re: module VM - Category only shows 2nodes not the 3de one.
Post by: balai on February 08, 2013, 10:11:18 AM
Custom Filters can be used too as category module for unlimited category tree depth
http://breakdesigns.net/extensions/custom-filters

Its in the free version
Title: Re: module VM - Category only shows 2nodes not the 3de one.
Post by: designfire_de on February 13, 2013, 09:21:57 AM
I had the same problem in a customers project yesterday.

So here is my solution that gives you the following features:

What to do:

echo printCategories($categories, $parentCategories, $class_sfx, $cache, $vendorId);

function printCategories($categories, $parentCategories, $class_sfx, $cache, $vendorId)
{
$html = '<ul class="menu'.$class_sfx.'" >';
foreach($categories as $category)
{
$category->childs = $cache->call( array( 'VirtueMartModelCategory', 'getChildCategoryList' ),$vendorId, $category->virtuemart_category_id );

$caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$category->virtuemart_category_id);
$cattext = $category->category_name;
$active_menu = in_array( $category->virtuemart_category_id, $parentCategories) ? 'active' : '';

$html .= '<li class="'.$active_menu.($category->childs ? ' parent' : '').'">
<div>'.JHTML::link($caturl, $cattext.($category->childs ? '<b class="caret"></b>' : '')).'</div>';

if($category->childs)
{
$html .= printCategories($category->childs, $parentCategories, $class_sfx, $cache, $vendorId);
}

$html .= '</li>';
}

$html .= '</ul>';

return $html;
}


This code will simply loop over all categories, create the category list element, check if there are category children and recursively do the same with all the children.

If you find any errors, please feel free to correct this solution!

Best regards,
Jonathan
Title: Re: module VM - Category only shows 2nodes not the 3de one.
Post by: vladivlad007 on February 17, 2013, 20:49:43 PM
 It did not work for me  :(
joomla 2.5.9. VM 2.0.18

Quote from: patrickit on February 06, 2012, 05:37:46 AM
Hi,

@BanquetTables.pro - using the joomla menu system - wouldn't that be fixed? What if we add new categories/sub categories to it?

@Janis There is a module but it didn't work in my vm2.0, if you have an earlier version of vm it may work - http://extensions.joomla.org/extensions/extension-specific/virtuemart-extensions/virtuemart-categories/9902 (http://extensions.joomla.org/extensions/extension-specific/virtuemart-extensions/virtuemart-categories/9902)

If it doesn't, and since there are no modules then I have a temporary workaround hack for you. Note that my workaround goes 1 extra level deep (3rd node), you can customize it for more nodes if required.
You can see a working demo here http://x-doria.ae/ (http://x-doria.ae/)
Hope it helps!

go to modules/mod_virtuemart_category/mod_virtuemart_category.php
find  (around line 46)
foreach ($categories as $category) {

      $category->childs = $cache->call( array( 'VirtueMartModelCategory', 'getChildCategoryList' ),$vendorId, $category->virtuemart_category_id );
add after it
//PL temp hack show 3rd node
      if($category->childs){
         foreach($category->childs as $child){
            $child->childs = $cache->call( array( 'VirtueMartModelCategory', 'getChildCategoryList' ),$vendorId, $child->virtuemart_category_id );
         }
      }
      //PL end

go to modules/mod_virtuemart_category/tmpl/all.php
find  (around line 32)
<div ><?php echo JHTML::link($caturl, $cattext); ?></div>

add after it
<?php if ($child->childs ) {   //PL temp hack show 3rd node
   ?>
      <ul class="menu<?php echo $class_sfx; ?>">
      <?php
         foreach ($child->childs as $grandchild) {      
            $caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$grandchild->virtuemart_category_id);
            $cattext = $grandchild->category_name;
            ?>
      <li>
         <div ><?php echo JHTML::link($caturl, $cattext); ?></div>
      </li>
      <?php } ?>
      </ul>
   <?php    } //PL end ?>
Title: Re: module VM - Category only shows 2nodes not the 3de one.
Post by: VirtueMart.cz on August 08, 2013, 14:23:26 PM
Quote from: designfire_de on February 13, 2013, 09:21:57 AM
I had the same problem in a customers project yesterday.

So here is my solution that gives you the following features:

  • Unlimited category levels
  • All active categories (and their parent categories) have the css class "active"
  • All categories with child categories have the css class "parent"
  • You don't have to modifiy any Virtuemart core module files (so an Virtuemart update won't delete your changes)
  • Attention: This solution might be slow on sites with a huge amount of nested categories
  • Attention: This solution only works, if you select "all" on the "Layout" config field

What to do:

  • Create a folder named "html" in your template folder if it doesn't already exist (i.e. /templates/beez5/html)
  • Create a folder named "mod_virtuemart_category" inside this folder
  • Copy the files "all.php" and "index.html" from "/modules/mod_virtuemart_category/tmpl" into this folder
  • Open the copied "all.php"
  • Delete everything after the first occurrence of "?>"
  • Insert the following lines before the first occurrence of "?>":

echo printCategories($categories, $parentCategories, $class_sfx, $cache, $vendorId);

function printCategories($categories, $parentCategories, $class_sfx, $cache, $vendorId)
{
$html = '<ul class="menu'.$class_sfx.'" >';
foreach($categories as $category)
{
$category->childs = $cache->call( array( 'VirtueMartModelCategory', 'getChildCategoryList' ),$vendorId, $category->virtuemart_category_id );

$caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$category->virtuemart_category_id);
$cattext = $category->category_name;
$active_menu = in_array( $category->virtuemart_category_id, $parentCategories) ? 'active' : '';

$html .= '<li class="'.$active_menu.($category->childs ? ' parent' : '').'">
<div>'.JHTML::link($caturl, $cattext.($category->childs ? '<b class="caret"></b>' : '')).'</div>';

if($category->childs)
{
$html .= printCategories($category->childs, $parentCategories, $class_sfx, $cache, $vendorId);
}

$html .= '</li>';
}

$html .= '</ul>';

return $html;
}


This code will simply loop over all categories, create the category list element, check if there are category children and recursively do the same with all the children.

If you find any errors, please feel free to correct this solution!

Best regards,
Jonathan

Hello everyone!

I took a designfire_de's solution that has many benefits and modify it for default current.php. So you have recursive "only view" modification which displays only the active categories and their children. Instructions are the same as all.php, just at the point 3. and 4. shall file current.php. Enjoy  8)

$class_sfx = 'VMmenu';
echo printCategories($categories, $parentCategories, $class_sfx, $ID, $cache, $vendorId);

function printCategories($categories, $parentCategories, $class_sfx, $ID, $cache, $vendorId, $control = true)
{
$html = '<ul class="'.$class_sfx.'" '.($control ? 'id="VMmenu'.$ID.'"' : '').'>';
foreach($categories as $category)
{
$category->childs = $cache->call( array( 'VirtueMartModelCategory', 'getChildCategoryList' ),$vendorId, $category->virtuemart_category_id );

$caturl = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$category->virtuemart_category_id);
$cattext = $category->category_name;
$active_menu = in_array( $category->virtuemart_category_id, $parentCategories) ? 'VmOpen' : 'VmClose';

$html .= '<li class="'.$active_menu.($category->childs ? ' parent' : '').'">
<div '.($active_menu == 'VmOpen' ? 'class="active"' : '').'>'.JHTML::link($caturl, $cattext).($category->childs ? '<span class="VmArrowdown"> </span>' : '').'</div>';

if ($active_menu=='VmOpen')
{
if($category->childs)
{
$class_sfx = 'menu';
$html .= printCategories($category->childs, $parentCategories, $class_sfx, $ID, $cache, $vendorId, false);
}
}
$html .= '</li>';
}

$html .= '</ul>';

return $html;
}


And here is CSS for change color of active categorie:

ul.VMmenu div.active a {
color: #FF1F1F;
}
Title: Re: module VM - Category only shows 2nodes not the 3de one.
Post by: Makis77 on January 30, 2014, 20:22:08 PM
Does this work in the current VM2 version?