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

Sub Category Listing

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 08-19-2004, 10:26 AM
 
twulff twulff is offline
 

Member
  
Join Date: Aug 2004
Posts: 12
 

Default Sub Category Listing

Ok, I have searched for it, but the samples I have found will obviously not work for 4.0x. or have to many modifications I do not wanna make
Anyhow, this is a sample how to get listed the subcats
  • Every time (but just the first sub cat level)
  • Or just the subcats of the actuell category

1) Create a new folder within the modules directory called: user_mods
2) place inside of this folder the following code as sub_cats.php
Code:
<? $CatID = $params['CatID']; #### List 1st subcat only #### $SubCatlist_1 = func_query("SELECT category, categoryid FROM xcart_categories WHERE parentid = '".$params['CatID']."' ORDER BY order_by"); if(count($SubCatlist_1) > 1) { foreach($SubCatlist_1 as $key => $value) { if(strlen($value['category']) > 4) echo "<FONT class=\"CategoriesList\" size=\"1\"><A href=\"home.php?cat=".$value['categoryid']."\" class=\"VertMenuItems\" style=\"font-size: xx-small;\">".$value['category']."</A></FONT> </font>"; } } ?>
3) change the code of the file skin1/customer/categories.tpl to
Code:
{else} {if $config.General.root_categories eq "Y"} {section name=cat_num loop=$categories} <FONT class="CategoriesList">{$categories[cat_num].category}</FONT> {*** twulff ***} {*** All Sub-Cats = 1 | Sub-Cats for the actuell Category = 2 | Set to 0 to do nothing ***} {assign var="CatList" value=2} {if $CatList eq 1} {*** Get all sub categories for the main categories ***} {include_php file="modules/user_mods/sub_cats.php" CatID=$categories[cat_num].categoryid} {elseif $CatList eq 2} {*** Get all sub categories for the ACTUELL main category ONLY ***} {foreach name=outer item=contact from=$location} {foreach key=key item=item from=$contact} {if $item eq $categories[cat_num].category} {include_php file="modules/user_mods/sub_cats.php" CatID=$categories[cat_num].categoryid} {/if} {/foreach} {/foreach} {/if} {*** twulff ***} {/section} {else} {section name=cat_num loop=$subcategories} <FONT class="CategoriesList">{$subcategories[cat_num].category}</FONT> {/section} {/if} {/if} {/capture}
4) upload the stuff to your server and pray but for me it's working

The good thing here is that you have to change the file categories.tpl only. Everything else is untouched and it is easy to extend some functions in there. I know, it's not the fine art of way to implement php within a smarty template, but it was the easiest way

have fun
__________________
Thomas
_______________________
X-Cart version 4.0.2 & xaffiliates
PHP 4.1.2
MySQL 3.23.49
Web server Apache
Operation system Debian Linux 3.0
Perl 5.006001
Reply With Quote
  #2  
Old 08-20-2004, 09:03 AM
  adpboss's Avatar 
adpboss adpboss is offline
 

X-Man
  
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 2,389
 

Default

Nice mod. I'll give this a try shortly.
Reply With Quote
  #3  
Old 09-20-2004, 11:21 PM
 
keavy keavy is offline
 

Member
  
Join Date: Apr 2004
Posts: 27
 

Default

I'm trying to achieve the same thing, but am getting an error when requesting this include file:
Code:
Warning: Smarty error: file:modules/user_mods/sub_cats.php is not readable in /myPath/shop/Smarty-2.6.3/Smarty.class.php on line 1082 Warning: _include(): Failed opening '' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /myPath/shop/Smarty-2.6.3/Smarty.class.php on line 1921


I've checked and double checked the spelling of my script and folders, but can't see what's wrong. Did you have to set any permissions or do anything else to get this to work?

Thanks
__________________
--
building with v4.0.3
Reply With Quote
  #4  
Old 09-20-2004, 11:55 PM
 
zilker zilker is offline
 

Advanced Member
  
Join Date: Feb 2003
Posts: 89
 

Default

I'm not sure if it matters on this mod or not but have you tried unclicking the "If ticked, the categories list always shows root categories:" under General Settings...General Options?
__________________
~zilker

uummm...perhaps you should tell me again.

http://www.designertrends.com
Version 4.0.6
Unix
Reply With Quote
  #5  
Old 09-21-2004, 08:12 PM
 
mizzlewillz mizzlewillz is offline
 

Advanced Member
  
Join Date: Apr 2004
Posts: 45
 

Default

This is a very nice mode, works perfectly. Is there a way to make it so the subcategory is highlighted (or font is changed or whatever) when it is selected. I am looking at the code but drawing a blank.

Does anyone have any ideas on this?

-Mike
Reply With Quote
  #6  
Old 10-04-2004, 07:38 PM
  adpboss's Avatar 
adpboss adpboss is offline
 

X-Man
  
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 2,389
 

Default

This mod shows disabled subcategories as well. That's not good.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



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 08:25 PM.

   

 
X-Cart forums © 2001-2020