[Templates] Stuck on getting data from a nested hash.
Lesley Binks
lesley.binks@zen.co.uk
Thu, 17 Aug 2006 22:54:53 +0100
Andy Wardley wrote:
> Lesley Binks wrote:
>> %menu = (
>> "Home" => {url => "./", name =>"Home",},
>> "Contact" => {url => "./contact.php", name=>"Contact",},
>> );
>
> Hi Lesley,
>
> Try it like this:
>
> @menu = (
> { url => ...etc... },
> { url => ...etc... },
> );
>
>> I create a reference to a hash thus :
>>
>> my $vars = {
>> ...
>> head => \%const_head,
>> sitemenu => \%menu,
>
> and this:
> sitemenu => \@menu,
>
> Then everything else should work.
>
Thanks Andy
That works if I use
[% FOREACH item IN sitemenu %]
<a href="[% item.url %]">[% item.name%]</a>
[% END %]
and ordering the menu in an array is a good idea! ;)
Thank you for your help.
Regards
L.