Gossamer Forum
Home : Products : Gossamer Links : Discussions :

<%if $global eq 'value'%>

Quote Reply
<%if $global eq 'value'%>
Hi,

this is maybe a very simple question, but I can't get this to work.

I have a global, which checks if there is '/redakteur' is part of the given parameter.

My global is very simple and looks like:
sub {
my ($name, $redakteur) = split /\//, $_[0];
my $result = 'false';
if ($redakteur eq 'redakteur'){
$result = 'true';
}
return $result;
}


When i put into the template:
<%redakteur('re/redakteur')%>
<%redakteur('re')%>
the following comes to screen: yes no (the first string includes '/redakteur', the second not, that means the global works correctly)

But if I put in the template:
<%if redakteur('re/redakteur') eq 'yes'%>
first
<%endif%>
<%if redakteur('re') eq 'yes'%>
second
<%endif%>

both 'first' and 'second' are displayed on the screen. But the second one doesn't equal to 'yes'!!!
If I take <%if $redakteur...%> it doesn't work, too!

What's wrong with this <%if...%>-clause??

Thanks, Tina
Quote Reply
Re: [tga] <%if $global eq 'value'%> In reply to
Hi,

You probably need something like;

Code:
sub {
my ($name, $redakteur) = split /\//, $_[0];
my $result = 0;
if ($redakteur eq 'redakteur'){
$result = 1;
}
return { tmp_result => $result };
}

Code:
<%redakteur('re/redakteur')%>
<%if tmp_result%>
first
<%endif%>

<%redakteur('re')%>
<%if tmp_result%>
second
<%endif%>

Basically, you can't do inline comparison ... i.e;

<%if test_global($catID)%>
yes
<%endfi%>

..but the global would return false, all the time (as the routine hasn't been executed).

Hope that helps.

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!