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)
-   -   Declaring a Category for Subcategories (https://forum.x-cart.com/showthread.php?t=50038)

cowsdonthack 10-05-2009 11:23 AM

Declaring a Category for Subcategories
 
Simply put. In the front page of the site I have a "Foreach" pulling from the Categories Array.

Each Category is coming out just fine, with descriptions and pictures and everything.

But I'm trying to get the Subcategories to show up for EACH category.

Unfortunately, whenever I try to use the syntax for Subcategories [$subcategories] it just pulls up the categories all over again. Image Included.

http://frozeninksecret.com/tmp/cat.jpg

Code:

{foreach from=$categories item=cat}
<div class="bot_products">
<a class="bot_products_img" href="home.php?cat={ $cat.categoryid }"><img src="{$xcart_web_dir}/image.php?id={ $cat.categoryid }&amp;type=C" alt="" /></a>
<a class="bot_products_txt" href="home.php?cat={ $cat.categoryid }"><b>{ $cat.category }</b></a>

<br /><br />
<div style="OVERFLOW: hidden; HEIGHT: 72px; font-size:12px">
{foreach from=$subcategories item=subcat}
<a href="home.php?cat={ $subcat.categoryid }">{ $subcat.category|escape }</a><br />
{/foreach}
</div>
</div>
{/foreach}


This is the section of the code it involves. In skin1/customer/homelist.tpl

Is there anyway you can load the subcategories within a category for a FOREACH array?

cowsdonthack 10-07-2009 04:44 AM

Re: Declaring a Category for Subcategories
 
A bump

cowsdonthack 10-08-2009 05:34 AM

Re: Declaring a Category for Subcategories
 
I've narrowed down another example of what I could use. This modification that's used on our site takes seven categories and lists their subcategories as well.
I want to modify it so that it can be used to display the subcategories in the new modification.

I've narrowed the code down to this in Include/Categories.php

Code:

$botcat_items = array();
$botcat_subcats = array();

$tmp = func_query('SELECT xcart_topmenu.*, xcart_categories.category FROM xcart_topmenu LEFT JOIN xcart_categories USING(categoryid) WHERE 1 ORDER BY position ASC');
    foreach($tmp as $item) {
        $botcat_items[$item['position']] = array('id' => $item['categoryid'], 'name' => $item['category']);
        $t = func_query('SELECT categoryid, category FROM xcart_categories WHERE avail = "Y" AND parentid = ' . $item['categoryid'] . ' ORDER BY order_by ASC');
            $botcat_subcats[$item['categoryid']] = $t;    }

$smarty->assign("botcat_items", $botcat_items);
$smarty->assign("botcat_subcats", $botcat_subcats);


I'm wondering. Is there a way to use func_query to get all the categories from the SQL database?

Is there any reference on how to use func_query, because I went to Smarty's website and looked at the website and didn't find a way to use the function.

-_- please help?

cowsdonthack 10-09-2009 08:47 AM

Re: Declaring a Category for Subcategories
 
Bump


All times are GMT -8. The time now is 09:41 AM.

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