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

accessing category description within smarty code?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 03-26-2005, 05:46 AM
 
International Living International Living is offline
 

Member
  
Join Date: Mar 2005
Posts: 23
 

Default 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
Reply With Quote
  #2  
Old 03-26-2005, 07:05 PM
 
International Living International Living is offline
 

Member
  
Join Date: Mar 2005
Posts: 23
 

Default

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
__________________
x-cart-Version 4.1.10
Reply With Quote
  #3  
Old 03-26-2005, 08:23 PM
 
Alphatim Alphatim is offline
 

Newbie
  
Join Date: Mar 2005
Location: Portugal, Lisboa
Posts: 4
 

Default

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.
__________________
X-Cart: Gold 4.0.13
OS: Linux (Fedora)
PHP: 4.3.10
MySQL: 4.0.22
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 07:58 AM.

   

 
X-Cart forums © 2001-2020