Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Showing all categories, subcategories and sub-subcategories

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 07-15-2015, 07:07 AM
  McGuireArmyNavy's Avatar 
McGuireArmyNavy McGuireArmyNavy is offline
 

Member
  
Join Date: Oct 2013
Posts: 29
 

Default Showing all categories, subcategories and sub-subcategories

I had my home page redone to put the categories on top instead of on the side. Using code from stackoverflow.com I was able to show subcategories together with parent categories. I need to go down a level or two, and can't seem to figure it out. Any ideas?

The code I used is below:
in include/common.php, I added the following under "Get categories menu data
Code:
+ + if (!isset($cat) || 0 == intval($cat)) { + $extended_categories = func_get_categories_list(0, true, true, 1); + + if (!empty($extended_categories)) { + $smarty->assign('extended_categories_list', $extended_categories); + } + }
and in /common_files/customer/categories.tpl, I added
Code:
<ul> {foreach from=$categories_menu_list item=c} <li><a href="home.php?cat={$c.categoryid}" title="{$c.category|escape}"><strong>{$c.category}</strong></a> <!-- list subcategories here--> {foreach from=$extended_categories_list item=ec} {if $ec.parentid eq $c.categoryid}<li><a href="home.php?cat={$ec.categoryid}" style="font-size:10px;">{$ec.category|escape}</a></li>{/if} {/foreach} {/foreach} </ul>

What do I do to go down further levels??
__________________
X-Cart Gold 4.6.4
www.mcguirearmynavy.com
Reply With Quote
  #2  
Old 07-16-2015, 04:50 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Showing all categories, subcategories and sub-subcategories

Looking in /include/func/func.category.php:
Code:
function func_get_categories_list($cat = 0, $short_list = TRUE, $need_sublevel = FALSE, $max_level = 0)

See that $max_level = 0 in the function arguments above? Looks to me like you are calling this function with this code:
Code:
$extended_categories = func_get_categories_list(0, true, true, 1);

So the last parameter you are feeding it is a 1, $maxlevel = 1. Try increasing it and see what you get.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #3  
Old 07-16-2015, 05:28 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default Re: Showing all categories, subcategories and sub-subcategories

v4.x - Up to 5 levels... ensure Modules > Flyout Menus is enabled + 'Cache the menu' is disabled.

Code:
<ul> {foreach from=$categories_menu_list item=c} <li><a href="home.php?cat={$c.categoryid}">{$c.category}</a> {if $c.childs} {foreach from=$c.childs item=sc name=sc} {if $smarty.foreach.sc.first}<ul>{/if} <li><a href="home.php?cat={$sc.categoryid}">{$sc.category}</a> {if $sc.childs} {foreach from=$sc.childs item=ssc name=ssc} {if $smarty.foreach.ssc.first}<ul>{/if} <li><a href="home.php?cat={$ssc.categoryid}">{$ssc.category}</a> {if $ssc.childs} {foreach from=$ssc.childs item=sssc name=sssc} {if $smarty.foreach.sssc.first}<ul>{/if} <li><a href="home.php?cat={$sssc.categoryid}">{$sssc.category}</a> {if $sssc.childs} {foreach from=$sssc.childs item=ssssc name=ssssc} {if $smarty.foreach.ssssc.first}<ul>{/if} <li><a href="home.php?cat={$ssssc.categoryid}">{$ssssc.category}</a></li> {if $smarty.foreach.ssssc.last}</ul>{/if} {/foreach} {/if} </li> {if $smarty.foreach.sssc.last}</ul>{/if} {/foreach} {/if} </li> {if $smarty.foreach.ssc.last}</ul>{/if} {/foreach} {/if} </li> {if $smarty.foreach.sc.last}</ul>{/if} {/foreach} {/if} </li> {/foreach} </ul>
__________________
xcartmods.co.uk
Reply With Quote

The following user thanks PhilJ for this useful post:
McGuireArmyNavy (07-16-2015)
  #4  
Old 07-16-2015, 06:12 AM
  McGuireArmyNavy's Avatar 
McGuireArmyNavy McGuireArmyNavy is offline
 

Member
  
Join Date: Oct 2013
Posts: 29
 

Default Re: Showing all categories, subcategories and sub-subcategories

Thank you guys, I will see if we cna make this work.
PhilJ, can I do this without flyout menus? I am using customized design for my categories.
__________________
X-Cart Gold 4.6.4
www.mcguirearmynavy.com
Reply With Quote
  #5  
Old 07-16-2015, 06:28 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default Re: Showing all categories, subcategories and sub-subcategories

You can, but why bother, just use the code.
__________________
xcartmods.co.uk
Reply With Quote
  #6  
Old 07-16-2015, 08:06 AM
  McGuireArmyNavy's Avatar 
McGuireArmyNavy McGuireArmyNavy is offline
 

Member
  
Join Date: Oct 2013
Posts: 29
 

Default Re: Showing all categories, subcategories and sub-subcategories

Thank you PhilJ.
I got it working, now I just need to tweak the design to get it back to where I really need it, but all the information is now showing.
__________________
X-Cart Gold 4.6.4
www.mcguirearmynavy.com
Reply With Quote
  #7  
Old 07-16-2015, 08:18 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default Re: Showing all categories, subcategories and sub-subcategories

cool.
__________________
xcartmods.co.uk
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:37 AM.

   

 
X-Cart forums © 2001-2020