X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Subcategory listing in subcategory page (https://forum.x-cart.com/showthread.php?t=58751)

Omron Khan 04-03-2011 09:27 PM

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

Omron Khan 04-05-2011 09:58 PM

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

nickff 06-28-2011 10:41 AM

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!


All times are GMT -8. The time now is 01:39 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.