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

Possible to get true/false tags from a global?

Quote Reply
Possible to get true/false tags from a global?
I'm trying to call a global, so it returns true if an entry exists with certain details, but it doesn't seem to be working very well Unsure

The global is:

Code:
sub {

# this is where we decide if a category is new or not...

my $ID = shift;

my $table = $DB->table('Category');
my $exists = $table->count( { Has_New_Links => "Yes", ID => $ID } );

if ($exists) { return 1; }
}

The tag I am using is;

<%if _has_new_links(8) == 1%>new<%endif%>

also tried;

<%if _has_new_links(8) eq "1"%>new<%endif%>
<%if _has_new_links(8)%>new<%endif%>

If I print out the tag, i.e;

<%_has_new_links(8)%>

...i tshows up as I would expect; 1 for links that the value is true on, and 0 for calls where it is not true.

I'm assuming this feature is supported in LSQL?

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] Possible to get true/false tags from a global? In reply to
Mmm you could shorted that significantly.

Code:
sub {
return $DB->table('Category')->count( { Has_New_Links => "Yes", ID => $_[0] } );
}
Quote Reply
Re: [Paul] Possible to get true/false tags from a global? In reply to
I tried your global, with the following tag;

<%if _has_new_links(1)%>new<%endif%>

It still doesn't show the "new" bit though Unsure I seem to remember having this problem a while back, but I'm not sure if a resolution was ever found Frown

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] Possible to get true/false tags from a global? In reply to
Andy:

I use a Yes/No tag in a global (in_prod)- something like if the date is today or later = Yes, if it is before today, No, and I use this code in the templetes:

<%if in_prod eq 'Yes'%>
<LI> Planned Release Date: <%Est_Date%> (Estimate).
<%else%>
<LI> Originally Released in <%Est_Date%> (Estimate).
<%endif%>

(actually, this goes on a lot more, this is a bit for an estimated release date- there is another, similar loop for if I know the eaxct date...)

Anyway, that works!


dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Possible to get true/false tags from a global? In reply to
LOL....I've only just got back to this one.

I can use it fine the way you are saying, but as soon as you try to pass a variable into it, you always get a false value.

ie;

Code:
<%if field_type(1)%>this<%endif%>

...and in the sub, something like;

Code:
sub {

my $ID = shift;
$ID = 1 ? return 1 : return 0;

}

If you try that, you will see that it always returns a false value. Is this a bug in LSQL, and is there a way around it ? Unsure

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] Possible to get true/false tags from a global? In reply to
AFAIK, you can't do

<%if global($ID)%>


You'll have to do something like

<%global($ID)%>
<%if tag_set_by_global%>
...
<%endif%>

where global is defined as
Code:
sub {
[set $boolean to 0 or 1]
return { tag_set_by_global => $boolean};
}

Hope this helps.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Possible to get true/false tags from a global? In reply to
Ah...interesting. I'll give that a go.

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: [yogi] Possible to get true/false tags from a global? In reply to
Yay! It works. I'm gonna have to remember that function.... I didn't know you could even set a new tag via global ....

Thanks loads yogi :)

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] Possible to get true/false tags from a global? In reply to
Andy,

If you return a hash from a global, those returned tags will be added to the available tags.

So, your global can create or alter tags, and the returned tags will replace or add into the current tags.

You used to have to pass the whole tags hash around, but in the last version or two, you can just pass back altered or new tags. If you want to delete tags, then you have to load and unload the tags hash. haven't tried that recently, :)

hash magic <G>

If you haven't read GT::Template in awhile, take a read. Every version it's upgraded. Pretty powerful <G>


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Possible to get true/false tags from a global? In reply to
Yeah, I think I may take a re-read of GT::Template again Smile

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!