Re: [SMARTY] how to use selfmade functions ?
| From: | messju mohr | Date: | Wed, 23 Jul 2003 14:03:54 +0000 |
| Subject: | Re: [SMARTY] how to use selfmade functions ? | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-9948@lists.php.net to get a copy of this message | ||
On Wed, Jul 23, 2003 at 03:50:42PM +0200, Florian Winkler wrote:
> Hi all ,
>
> I have a function in my script which I use to transform urls into links and
> html into htmlentities.
>
> function interpret_html($text)
> {
> //do something with $text
> return $text;
> }
>
> know I need to use this function in my template , because the array which I
> want to print out is already
> rendered.The only possibility I know is to walk through the array and apply
> this funktion to each element but if I could use this function in my
> template this would be much more comfortable.
you can use your function as a modifier:
{$var|interpret_html}
or even
{"text"|interpret_html}
if you have $smarty->security=false (which is likely, since it is the
default setting) you can use any php-function as a modifier.
see http://smarty.php.net/manual/en/language.modifiers.php
for reference.
greetings
messju
> Thanks in advance
> greetz
> fLo
>
> PS : Unfortunately I've deleted the message in which messju showed me how
> to do something like ( for($i = 1;$i<=10;$i++){...} in a template withouht
> arrays. Can you please say it a second time :) ?
see: http://marc.theaimsgroup.com/?l=smarty-general&m=105861760508792&w=2
:)