Re: How to use a Smarty variable outside the template file ?
| From: | Luc Saint-Elie | Date: | Tue, 24 Jul 2001 05:59:15 +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-1267@lists.php.net to get a copy of this message | ||
Hello,
The word "destroyed" was wrong (its my nerves that are destroyed ;-)) .. I perhaps found out where the mess is.
When doing :
$file = 'xml_files/'.$section.'/'.$file;
$xml_data = $tpl->fetch('../'.$file);
$xml = new XML($xml_data);
What is piped into the XML parser, the stream containing the XML file read by $xml_data = $tpl->fetch('../'.$file); or the compiled result of this "fetch" action ?
In the second case, the problem is perhaps that the file is no more recognized as a regular XML one.
In templates_c the compiled xml file is this way :
<?php /* Smarty version 1.4.4, created on 2001-07-24 07:46:46
compiled from ../xml_files/cachecache/cachecache.xml */ ?><?php echo '<?xml version="1.0" encoding="ISO-8859-1"?>'; ?> <article>
<category/>
<version><![CDATA[.......and so on
The 3 first lines apparently fool the XML parser....
Luc
At 13:55 23/07/01 -0500, Monte Ohrt wrote:
How was it destroyed exactly? Are there curly braces that might affect how Smarty parses the file? Can you attach before/after files to compare? Luc Saint-Elie wrote: Hello, (yeah I know.. its still me..) $smarty->fetch("myXMLfile"); send back a destroyed XML file, the tags are gone and so are the oppenning <[CDATA[.. I tried with a simple $smarty->fetch() followed by a echo... its rather clear... Luc At 13:21 23/07/01 -0500, you wrote:Your best bet is to have Smarty parse the XML file, then run that through your xml parser. One way or another, you will need the data parsed by your xml parser and by Smarty. // assign vars to smarty here // parse xml file through smarty $xml_data = $smarty->fetch("cachecache.xml"); // parse the xml data into arrays xml_parse($xml_data); // assign your xml arrays to smarty here // display your template $smarty->display("index.tpl");