| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Display a list of Subcategories from a Specific Category | ||||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
![]() I have a really customized categories.tpl
The main reason is because I want to limit what people see on each page as far as category pages are concerned. I use things like: {if $cat eq 33 or $current_category.parentid eq 33} ...all my hand crafted links... {/if} but I would really like to automate the building of these links - do you know of a simple way to loop through all Subcategories in a specific Category then display them in a simple list? ex: loop through all subcategories that exist in category 33 and display: <li class="subCategoryLink"><a href="home.php?cat=34">Subcategory Name</li> I tried to follow some other threads but they seem to be way overr the top because they are trying to make this a gloabl category listing template. I really want to keep my specific to each category page. Any help would be great.
__________________
------ Brian Portland web design / development X-Cart 4.1.9 (a few carts) X-Cart 4.2.0 (1 cart so far) |
|||||||||
#2
|
|||||||
|
|||||||
![]() I needed this too, so I looked at fly-out menu examples and came up with this -
I like to show third-level categories in fourth level subcategories (i.e. all subcategories that share the same parent category of the current category) - --------------------- {foreach from=$categories item=c}{* list ROOT categories *} {if $c.subcats gt 0} {foreach from=$c.subcats item=c2 name=c2}{* list 2nd level subcategories *} {if $c2.categoryid eq $current_category.parentid} {assign var='parent_category' value=$c2.category}{* get the name of the Parent Category *} {/if} {if $c2.subcats gt 0} {foreach from=$c2.subcats item=c3 name=c3}{* list 3rd level subcategories *} {if $c3.parentid eq $current_category.parentid} <a href="home.php?cat={$c3.categoryid}">{$c3.category }</a><br /> {/if} {/foreach} {/if} {/foreach} {/if} {/foreach} <a href="home.php?cat={$current_category.parentid}">{ $parent_category}</a><br />{* link to Parent Category at end of list *} ---------------- This creates a basic array of categories that share the same parent category of the current 4th level category. You could, of course, easily modify it to show deeper levels.
__________________
X-Cart Gold 4.1.9 Gift Registry/Special Offers Advanced mini-cart XC-SEO Mulltiple Category/Product Templates Also bought/recently viewed Feedback reviewer/viewer bundle Marketing Manager Pro bundle many more mods |
|||||||
#3
|
|||||||
|
|||||||
![]() Quote:
Could you list the tpl file this code goes in and the before and after code showing how this code is added to that tpl file? |
|||||||
#4
|
|||||||
|
|||||||
![]() I add the code to "/skin1/customer/main/subcategories.tpl" just below -
{if $tmp and $products ne "" } and above - <br clear="left" /> <hr size="1" noshade="noshade" /> {/if}
__________________
X-Cart Gold 4.1.9 Gift Registry/Special Offers Advanced mini-cart XC-SEO Mulltiple Category/Product Templates Also bought/recently viewed Feedback reviewer/viewer bundle Marketing Manager Pro bundle many more mods |
|||||||
#5
|
|||||||
|
|||||||
![]() Quote:
Thanks! |
|||||||
#6
|
|||||||
|
|||||||
![]() What is subcats?
Thx
__________________
Gold, X-Cart version 4.1.10 |
|||||||
#7
|
|||||||
|
|||||||
![]() "subcats" = "sub-category" type of category
i.e. a "sub-category" is any category which you set up, which is not a "root" level category. See category management wihin X-Cart admin to understand more... the "Root level" is shown for only the top (1st) level of categories you have added (any categories added below the root level ones are called a sub-category).... Hope comment helps, cheers, Asiaplay
__________________
X-Cart Gold version 4.1.9 (plus built in X-Cart bugs!) |
|||||||
#8
|
|||||||
|
|||||||
![]() Quote:
If i display $subcats or use your code I get nothing. So $subcats does not exist as a variable.
__________________
Gold, X-Cart version 4.1.10 |
|||||||
#9
|
|||||||
|
|||||||
![]() Check your own code to see what variable was used in original code (and use logic)... the variables sometimes change depending on version you use (but surprised this one does)... and I have no idea what version you are using (as never heard of default version Alla - perhaps update your signature). This is not my code, I was just trying to explain to you the meaning of $subcats ...
![]() Cheers, Asiaplay
__________________
X-Cart Gold version 4.1.9 (plus built in X-Cart bugs!) |
|||||||
#10
|
|||||||
|
|||||||
![]() in subcategories.tpl, $subcategories is NULL if the page lists the products from the subcategory
Is there any other variable that will alow me to display the subcategories on this page http://demo.x-cart.com/demo/home.php?cat=23 Thank You
__________________
Gold, X-Cart version 4.1.10 |
|||||||
|
|||
X-Cart forums © 2001-2020
|