View Single Post
  #2  
Old 06-28-2011, 10:44 AM
 
nickff nickff is offline
 

Senior Member
  
Join Date: Aug 2010
Posts: 132
 

Default Re: Display Subcategories of Parent, While in Subcategory

SOLVED thanks to this post - http://forum.x-cart.com/showthread.php?p=320214#post320214

Here's how I did it:

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