[dev] Horde templates short examples
Mike Cochrane
mike at graftonhall.co.nz
Fri Dec 20 11:09:11 PST 2002
> ----- Message from marko@oblo.com ---------
>
> ARRAY WITH KEYS
> ----
> PHP:
> //We now have an array with keys to pass
> $foo = array( 'city' => 'paris',
> 'country' => 'france',
> 'language' => 'french'
> );
> //Again it is set the same way into the template object
> $template->set('foo', $foo);
>
> TEMPLATE:
> <html><body>
> we have many foo values:
> <loop:foo>
> <li><tag:foo.city />, located in <tag:foo.country /> where
> <tag:foo.language
> /> is spoken
> </loop:foo>
> </body></html>
>
> ** Note: you need to have a loop array to parse through variables with keys.
> using the tags <tag:foo.somekey /> on their own without the loop tag will not
> work.
Chuck, this is what the last commit to Template.php caused. You could do this
without the loop tag orginially.
And you can have references to and array and key outside the loop so long as you
have a loop somewhere in the template. So in my experience (haven't tested on
this one in particular) this should produce the same output.
<loop:foo>
</loop:foo>
<html><body>
we have many foo values:
<li><tag:foo.city />, located in <tag:foo.country /> where
<tag:foo.language /> is spoken
</body></html>
- Mike :-)
More information about the dev
mailing list