Re: [SMARTY] {php} and assign()

boots <[email protected]>
Newsgroups gmane.comp.php.smarty.general
Message-ID <[email protected]>
Not withstanding Evan's (correct) comments, the anwser is:

{php}
$this->assign('data', fetch_some_data_from_db());
{/php}

Now that you know -- don't do it. If you don't want to do it from your
controller script, at least wrap it in a plugin.

--- Evan Wagner <[email protected]> wrote:

> That's not really what smarty was designed for. You want to seperate
> your logic and presentation. For example, if you wanted to assign the
> $data variable in smarty to fetch_some_date_from_db(); then you would
> do it like this:
> 
> $smarty->assign('data', fetch_some_data_from_db());
> 
> And thus for you to show what fetch_some_data_from_db() has done you
> would just need this in your template file:
> 
> {$data}
> 
> If you cannot understand this you need to at least read the crash
> course on the Smarty site.
> 
> On 7/17/05, Fredrik Arild Takle <[email protected]> wrote:
> > Hi there,
> > 
> > inside a template I do the following
> > 
> > {php}
> >     $data = fetch_some_data_from_db();
> > {/php}
> > 
> > 
> > <head>
> > <title>Test</titel>
> > </head>
> > <body>
> >     {data}
> > </body>
> > 
> > 
> > My problem is how do I assign the $data variable?


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.