Gossamer Forum
Home : Products : Gossamer Links : Discussions :

global question ?

Quote Reply
global question ?
Theres a global I'm playing with and I realized when my links print its not coming out the way I want it to.

For example I'm using if statements

how can I get my global to print and make it able to recognize an if statement ?

heres the example:

<%if detailed%><%endif%>

<%ifnot detailed%><%endif%>



Thanks in advance Blush
Quote Reply
Re: [incik] global question ? In reply to
Sorry, I'm not quite sure what you are asking Unsure Could you please re-phrase your question...

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: [incik] global question ? In reply to
As a guess, are you trying to use the if statements in the global? If so you will need to write them in perl as the tags are only parsed when they are in the templates - you can't use them in a global. A perl if statement looks something like this:

if ($tags->{detailed}) { Do this;}

else { Do this;}

where the 'Do this' is a perl statement. If you give some more information - i.e. your global so far - you'll get a lot more help.

Laura.
The UK High Street
Quote Reply
Re: [afinlr] global question ? In reply to
The global I'm playing with can be found here and its the second post by Alex

http://www.gossamer-threads.com/...orum.cgi?post=186817

afinlr is correct in what I'm trying todo

What does the { Do this;} statement look like written in perl ?

Also heres the entire if statement that I need written in perl. If you can help me write it I'd greatly appreciate it.

<%if Detailed%>
<ul>
<li><%body_font%><a class="category_links" href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>&Detailed=1"><%Title%></a></font>
<%endif%>
<%ifnot Detailed%>
<ul>
<li><%body_font%><a class="category_links" target="_blank" href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%Title%></a>
<%endif%>



Thanks Smile
Quote Reply
Re: [incik] global question ? In reply to
I've modified the global and added the if statements in. I'm not quite sure what the <%if Detailed%> tag is? I've just put it in as a tag but I'm wondering whether it is a field in your Links table to say that some links go to detailed pages? If so, this will need modifying slightly.

sub {
my $id = shift;
my $tags = shift; #you need this to get all the available tags
my $db = $DB->table ('Links','CatLinks');
$db->select_options ('ORDER BY Hits DESC', 'LIMIT 10');
my $sth = $db->select ( { 'CatLinks.CategoryID' => $id}, ['Links.ID', 'Links.Title'], { isValidated => 'Yes'} );
my $popularcategory;
while (my ($id,$name) = $sth->fetchrow_array) {
if ($tags->{Detailed}){
$popularcategory .= qq~ <ul> <li><$tags->{body_font}><a class="category_links" href="$CFG->{db_cgi_url}/jump.cgi?ID=$id&Detailed=1">$name</a></font> ~;
}
else {
$popularcategory .= qq~ <ul> <li><$tags->{body_font}><a class="category_links" href="$CFG->{db_cgi_url}/jump.cgi?ID=$id">$name</a> ~;
}
}
return $popularcategory;
}


Haven't tested it so it might need debugging but it should point you in the right direction.

Laura.
The UK High Street