Re: [SMARTY-DEV] 2.4.2 and 2.3.0 incompatibilities
| From: | Monte Ohrt | Date: | Thu, 13 Feb 2003 14:55:25 +0000 |
| Subject: | Re: [SMARTY-DEV] 2.4.2 and 2.3.0 incompatibilities | ||
| References: | 1 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-686@lists.php.net to get a copy of this message | ||
You can access numerical arrays directly like that:
$page[0][0]
But this won't work:
$page["template"]["content"]
That should give a syntax error, the way to access associative arrays in
Smarty is:
$page.template.content
This won't work either (as you expect):
$page[template][content]
That is how you access values within section loops.
Monte
On Thu, 2003-02-13 at 06:09, Carsten Bleek wrote:
> (second try, with correct sender)
>
> Hi,
>
> I´ve tried to upgrade to 2.4.2 but had to switch back
> to 2.3.0 because of some incompatibilities.
>
> Also its documented not to use quotes I want to point this out.
>
> {include file=$page["template"]["content"]}
>
> produces the following PHP:
>
> $this->_smarty_include($this->_tpl_vars['page']."["template"]["content"]",
> array());
>
> which causes a parse error:
>
> Solution is to remove the quites like
> {include file=$page[template][content]}
>
>
> There seems to be annother problem with the scope of variables
> in included templates. I´ve attached a small archiv containing
> all needed files to reproduce the errro:
>
> The following 2 templates:
>
> 1. cat generic.tpl
> ------------------
> Description=<b>{$page.description}<b><br>
> {include file=$page[template][content]}
>
> 2. cat include.tpl
> ------------------
> Content:= <b> {page.content} </b>
>
> accessed with the following PHP code:
> -------------------------------------
> $page["template"]["content"]="include.tpl";
> $page["description"]="description";
>
> $smarty=new Smarty_OpenHR;
> $smarty->assign("page",$page);
> $smarty->display('generic.tpl');
>
>
> is resulting into the folloing compiled PHP code
> -------------------------------------------------
> <?php /* Smarty version 2.4.2, created on 2003-02-13 13:01:02
> compiled from generic.tpl */ ?>
> Description=<b><?php echo
> $this->_tpl_vars['page']['description']; ?>
> <b><br>
> <?php $_smarty_tpl_vars = $this->_tpl_vars;
>
> $this->_smarty_include($this->_tpl_vars['page'][$this->_sections['template']['index']][$this->_sections['content']['index']]
> $this->_tpl_vars = $_smarty_tpl_vars;
> unset($_smarty_tpl_vars);
> ?>
>
>
> which produces the following (browser) output:
> ----------------------------------------------
> Description=description
>
> Warning: Smarty error: unable to read template resource: "" in
> /home/carsten/public_html/jobs/lib/Smarty/Smarty.class.php on line 999
> ?>
--
Monte Ohrt <monte@ispi.net>