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)
-   -   Weird Smarty Bracket Problem (https://forum.x-cart.com/showthread.php?t=32982)

skipmartin 08-02-2007 07:52 AM

Weird Smarty Bracket Problem
 
I am displaying data from a table and I am unable to modify the column names. The problem is that one of the column names has brackets in it, for example 'ccost[0]'

When I try to display the value of that column using {$product.proddata.ccost[0]} smarty thinks I am trying to display a value of an array 'ccost'

Is there any way to trick smarty into using 'ccost[0]' as the actual fieldname and not a reference to an array?

Thanks,
Andy

geckoday 08-02-2007 09:57 AM

Re: Weird Smarty Bracket Problem
 
I would change the query to rename the field on retrieval. e.g.
Code:

SELECT ...,`ccost[0]` AS ccost0, ... FROM ....
Then you can refer to it as {$product.proddata.ccost0}

Another option might be:
Code:

{assign var='ccost0' value='ccost[0]'}
{$product.proddata.$ccost0}


skipmartin 08-02-2007 10:02 AM

Re: Weird Smarty Bracket Problem
 
Thanks - the assign var solution worked perfectly.


All times are GMT -8. The time now is 01:07 AM.

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