Gossamer Forum
Home : Products : Gossamer Forum : Development, Plugins and Globals :

Usign a hashref in a template

Quote Reply
Usign a hashref in a template
Hi all

Got a small issue. I have a sub that returns a hashref to be used by a template to do lookups (validate states) without using too much DB ressources. My problem is that I don't know how to access this hash in the template tags (<%... %>).

I've tried the usual syntax : <% myhashref->{myitem} %> but this always returns 0, even for valid items.
Using the dump function of GT::Forum, I can see my Hash with all its values.

I've also tries writing a new perl sub that would accept this hash as arguement. On the other side, my hashref got transformed into a plain string holding the name of the variable holding the hashref...?

So, is there a way to use a hashref in a template outside of a loop?

If anybody knows...

Thank you!

Eric.
Quote Reply
Re: [rikgig] Usign a hashref in a template In reply to
You should take a read through the GT::Template documentation (admin.cgi?do=help&topic=GT/Template.html).

Hashes in GT::Template are accessed via <%hash.key%>.

Adrian
Quote Reply
Re: [brewt] Usign a hashref in a template In reply to
Hi Adrian

Thx a lot, I'll try that.

I have read the Template docs, I've done it again this morning to see if I missed something but seems not. Maybe I don't run on the right version of the framework...

Testing...
Thanks again.
Eric