Re: [SMARTY] Appening value to tpl var
| From: | Oscar Fernandez Sierra | Date: | Fri, 05 Jul 2002 06:15:59 +0000 |
| Subject: | Re: [SMARTY] Appening value to tpl var | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-5204@lists.php.net to get a copy of this message | ||
Hello
append is for variables of type array (it internally converts to an
array), so you have to indicate
the index of the element you want to access: try $Name[0], or iterate
through the array.
PD: I haven't checked my solution, I'm just supposing it would work.
Greetings,
Roger Thomas wrote:
>
> i tried to use the append method to append a template var $Name with "Fred".
> i expect smarty will generate a template var called $NameFred, but it doesn't.
> please advise.
>
> my template file: t.tpl
> -----------------------
> test<br>
> {$Name}<br>
>
> my php script
> -------------
> <?
> require "Smarty.class.php";
> $tpl = new Smarty;
>
> $tpl->append("Name","Fred");
> $tpl->assign("NameFred","This is your name");
> $tpl->display("t.tpl");
> ?>
>
> and in templates_c
> ------------------
> <?php /* Smarty version 2.0.1, created on 2002-07-05 09:31:14
> compiled from t.tpl */ ?>
> test<br>
> <?php echo $this->_tpl_vars['Name']; ?>
> <br>
>
> OUTPUT from browser:
> --------------------
> test
> Array
>
> rgds.
>
> __________________________________________________
> Do You Yahoo!?
> Sign up for SBC Yahoo! Dial - First Month Free
> http://sbc.yahoo.com
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
Oscar Fernandez Sierra | Mundinteractivos - El Mundo |
Area de Internet | Pradillo, 42 |
oscar@el-mundo.net | 28002 - Madrid (SPAIN, EU) |
http://www.elmundo.es/ | Tel: (+34) 915864800 (Ext: 4616) |