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)
-   -   accessing category description within smarty code? (https://forum.x-cart.com/showthread.php?t=13026)

International Living 03-26-2005 05:46 AM

accessing category description within smarty code?
 
hey guys

i have some smarty code that works - and outputs the category names and their ids and links.

Code:

{section name=cat_num loop=$categories}



{$categories[cat_num].category}: Learn more</p>

{/section}


what i want to do is throw the category description in there as well. i had hoped that throwing in this:

Code:

{$categories[cat_num].description}

might do the trick, but apparantly not (it seemed logical). can anyone reveal to me the secret?

thanks in advance,

murray

International Living 03-26-2005 07:05 PM

figured it out -- thought i'd post it here in case anyone was curious.

in categories.php, the code read:

Code:

if ($short_list) {
                $to_search = "$sql_tbl[categories].categoryid,$sql_tbl[categories].parentid,$sql_tbl[categories].categoryid_path,$sql_tbl[categories].category,$sql_tbl[categories].product_count,$sql_tbl[categories].avail,$sql_tbl[categories].order_by";
        } else {
                $to_search = "$sql_tbl[categories].*";
        }


i added the field i needed (description) to the SQL statement like this:

Code:

if ($short_list) {
                $to_search = "$sql_tbl[categories].categoryid,$sql_tbl[categories].description,$sql_tbl[categories].parentid,$sql_tbl[categories].categoryid_path,$sql_tbl[categories].category,$sql_tbl[categories].product_count,$sql_tbl[categories].avail,$sql_tbl[categories].order_by";
        } else {
                $to_search = "$sql_tbl[categories].*";
        }


this then allowed me to use

Code:

{$categories[cat_num].description}

in my categories.tpl

Alphatim 03-26-2005 08:23 PM

Hello Murray,

Nice hint.

Another hint. There is a simple way to see the structure of the hash:
Code:

{foreach name=foo item=bar from=$categories}
  {foreach key=key item=value from=$bar}
    {$key}: {$value}

  {/foreach}
 

 

{/foreach}


Best regards.


All times are GMT -8. The time now is 06:56 PM.

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