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

Templates recognising a global hash

Quote Reply
Templates recognising a global hash
My global works fine. It takes all the fields from one row in a table and puts it in a hash.

Code:
sub {
my $fitemp = $IN->param('fi') || 1;
my $menudata = $DB->table('F_menus')->select({ fran_id => $fitemp })->fetchrow_hashref;
return ($menudata);
}


But how do I access the information in it?

The templates will recognise an item in my global, for example:
<%menu5a%>

but....
ONLY if I have referred to the global itself somewhere, for example.
<%if menudata%><%endif%>

There must be a better way! Perhaps an alteration to my global?
Quote Reply
Re: [tora] Templates recognising a global hash In reply to
Globals don't execute automatically. You need to call them for them to run (for the instance of a global with code in it). For something that returns a hash, you can just put it at the top of the template (or wherever really): <%menudata%>.

Adrian
Quote Reply
Re: [brewt] Templates recognising a global hash In reply to
Thanks!!SmileSmile