Gossamer Forum
Home : Products : Gossamer Links : Discussions :

can I access hash_ref with variable in templates

Quote Reply
can I access hash_ref with variable in templates
Hi,

I am trying to access a variable I can Dump with another variable within a template.
I have the following in a Plugin:
Code:
$countries->{AT} = "Austria";
$countries->{CH} = "Swizerland";
$mycountry = "CH";
All of the above are available as template variables.
I am trying to do something like:
Code:
<%if countries.$mycountry%>
ok
<%else%>
not ok
<%endif%>
I would be happy to get a hint if there is a way to do what I am trying to do.

Cheers

n||i||k||o
Quote Reply
Re: [el noe] can I access hash_ref with variable in templates In reply to
Sometimes it helps to post a question to solve it.
Actually I had
Code:
<%udx_shop.StandardDelivery.Long.$address.Primary_Invoice.Country%>
and
Code:
<%udx_shop.StandardDelivery.Long.${address.Primary_Invoice.Country}%>
which did not work but
Code:
<%set localcountry = $address.Primary_Invoice.Country%>
<%udx_shop.StandardDelivery.Long.$localcountry %>
works like a charm.

Cheers

n||i||k||o
Quote Reply
Re: [el noe] can I access hash_ref with variable in templates In reply to
The amount of times I've done exactly that (posted a question - then 5 minutes later, found a solution ;)) , is mad. Sometimes I actually go to write a post, with the intent of the answer coming to me while I write it out Whistle

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] can I access hash_ref with variable in templates In reply to
I know exactly what you mean Laugh