Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

Global help

Quote Reply
Global help
I'm trying to have a global check if a post author is in a particular group, and then assign them a particular color if they are, but it's behaving oddly. When I do just <%user_groupcheck($user_id)%> it correctly returns what I need it to, either 1 or 0. However, when I use it as I need to, within an if statement, it acts as though it's always false.

<%if user_groupcheck($user_id)%><%grouphtml%><%endif%>

The global I have is:
'user_groupcheck' => 'sub {
my $uid = shift;
my $count = $DB->table("UserGroup")->count({
group_id_fk => 18,
user_id_fk => $uid
});
return ($count and $count > 0);
}',


Realiiity.com Forums
Quote Reply
Re: [ellipsiiis] Global help In reply to
I don't think you can do that. Try:
Code:
<%set groupcheck = user_groupcheck($user_id)%><%if groupcheck%><%grouphtml%><%endif%>

Adrian
Quote Reply
Re: [brewt] Global help In reply to
Yeah, I'm almost definate you can't do that. Similar problem in LinksSQL. I normally get around it by doing;

Code:
<%set_global($Field)%>

<%if tag_name%>foo<%endif%>

sub {

my $val = $_[0]; # get the value passed in...

# do something

return { tag_name => $val };

}

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates