Re: How to use a Smarty variable outside the template file ?
| From: | Monte Ohrt | Date: | Tue, 24 Jul 2001 13:09:17 +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-1277@lists.php.net to get a copy of this message | ||
The compiled code isn't what you are after, and it shouldn't affect
anything.
$xml_data = $smarty->fetch("foo.xml");
This should make smarty process the foo.xml file, replacing smarty tags
with the appropriate information.
What does $xml_data look like when it comes out of smarty? It should
look exactly the same, except anything between { } should be replaced
with something else.
Luc Saint-Elie wrote:
>
> 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");
>
> ---
> You are currently subscribed to smarty as: monte@ispi.net
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/