Re: How to use a Smarty variable outside the template file ?
| From: | Luc Saint-Elie | Date: | Mon, 23 Jul 2001 18:14:00 +0000 |
| Subject: | Re: How to use a Smarty variable outside the template file ? | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-1252@lists.php.net to get a copy of this message | ||
At 09:24 23/07/01 -0500, Monte Ohrt wrote:
You will need to include the external source as a template. If there are no other curly braces in the XML file, should should be able to just include it. {include file="foo.xml"} And if this XML file is coming from a database or other resource, you will want to create a resource function and register it. {include file="xml:foo.xml"}Hello, I tried, this doesn't work.. and that seem rather normal. If I do that the templates system tries to include my XML file that is absolutely not what I want to do. The conclusion is that I absolutely don't understand.... Here is the sequence : step 1 : a XML file (cachecache.xml) contains somes variables (for example {$ip} ) step 2 :a php file ( xmlprocess.php) calls this XML file and processes it using phpxml class the result is two arrays step 3 : the php file "assigns" the resulting arrays to the template (display.article.tpl) step 4 : the php file "assigns" several variables corresponding to the variables from step 1 to the template (display.article.tpl) step 5 : the php file "displays" the main template (index.tpl) that then "includes" display.article.tpl If i set debugging to true, the assigned template variables are OK.. my problem is that thE SEARCH/replace is done on the template (display.article.tpl) file and not in the content of the array (the one that contains the XML data). Perhaps the solution would be to do this work in the php file to search inside the array and replace the {...} placeholder by the actual value or to do this at processing time when parsing the XML file.... Luc