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

Subcategory listing in subcategory page

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 04-03-2011, 09:27 PM
 
Omron Khan Omron Khan is offline
 

Member
  
Join Date: Jan 2011
Posts: 14
 

Default Subcategory listing in subcategory page

I am kinda in a serious predicament here . Check this link
http://www.taqshop.com/xcart/home.php?cat=333
On the left sidebar you can see the sub catgeories of the parent category Technology.

I want to display the same subcategories in the subcategories individual pages also. like here http://www.taqshop.com/xcart/home.php?cat=388

Current code of mine which i use to display the subcategory is
Code:
<ul> {foreach from=$categories item=subcategory} <li> <a href="home.php?cat={$subcategory.categoryid}">{$subcategory.category|escape}</a></li> {/foreach} </ul>
but with this i cant display the subcategories in the subcatgeory page. It will only display the subcategories of the current subcategory.

Any help will be appreciated
__________________
x-cart-4.4.1-pro
Reply With Quote
  #2  
Old 04-05-2011, 09:58 PM
 
Omron Khan Omron Khan is offline
 

Member
  
Join Date: Jan 2011
Posts: 14
 

Default Re: Subcategory listing in subcategory page

Anyway solved this issue. i made a new tpl file and called it in the sidebar. Here's the code in the tpl file:


Code:
{php} $t = $this->get_template_vars('cat'); $result=mysql_query("select * from xcart_categories where categoryid=$t"); while($row=mysql_fetch_array($result)) { $cid=$row['categoryid']; $pid=$row['parentid']; $cat=$row['category']; } {/php} <ul> {php} if($pid==0){ $res=mysql_query("select * from xcart_categories where parentid=$t"); while($row1=mysql_fetch_array($res)) { $cat12=$row1['category']; $cid12=$row1['categoryid']; {/php}<li><a href="home.php?cat={php}echo $cid12; {/php}">{php} echo $cat12;{/php}</a></li>{php} } }else { $res=mysql_query("select * from xcart_categories where parentid=$pid"); while($row1=mysql_fetch_array($res)) { $cat12=$row1['category']; $cid12=$row1['categoryid']; {/php}<li><a href="home.php?cat={php}echo $cid12; {/php}">{php} echo $cat12;{/php}</a></li>{php} } } {/php} </ul>


if you wanna see a live demo of it check here
http://www.taqshop.com/xcart/home.php?cat=361
__________________
x-cart-4.4.1-pro
Reply With Quote

The following 2 users thank Omron Khan for this useful post:
hollaratbear (06-16-2011), nickff (06-28-2011)
  #3  
Old 06-28-2011, 10:41 AM
 
nickff nickff is offline
 

Senior Member
  
Join Date: Aug 2010
Posts: 132
 

Default Re: Subcategory listing in subcategory page

Brilliant Solution, Omron.

I implemented like so, using a dropdown menu at the top of my category pages:

In subcategories.tpl:
HTML Code:
{include file="customer/main/subcategories_dropdown.tpl"}

In subcategories_dropdown.tpl:
HTML Code:
{php} $t = $this->get_template_vars('cat'); $result=mysql_query("select * from xcart_categories where categoryid=$t"); while($row=mysql_fetch_array($result)) { $cid=$row['categoryid']; $pid=$row['parentid']; $cat=$row['category']; } {/php} <select name="mySelect" class="gender-select" onchange="if(this.options[this.selectedIndex].value != '')window.top.location.href=this.options[this.selectedIndex].value"> <option value="Select A Gender">mens/womens/youth</option> {php} if($pid==0){ $res=mysql_query("select * from xcart_categories where parentid=$t"); while($row1=mysql_fetch_array($res)) { $cat12=$row1['category']; $cid12=$row1['categoryid']; {/php} <option value="home.php?cat={php}echo $cid12; {/php}">{php}echo $cat12;{/php}</option> {php} } }else { $res=mysql_query("select * from xcart_categories where parentid=$pid"); while($row1=mysql_fetch_array($res)) { $cat12=$row1['category']; $cid12=$row1['categoryid']; {/php} <option value="home.php?cat={php}echo $cid12; {/php}">{php}echo $cat12;{/php}</option> {php} } } {/php} </select>

Works perfectly!
__________________
nick hoag
looking forward to the future
http://thefutureforward.com
xcart versions 4.2.x, 4.3.x, 4.4.x
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 01:12 AM.

   

 
X-Cart forums © 2001-2020