Gossamer Forum
Quote Reply
Global question
Hi

We are using the following global to identify links with a url that ends with pdf (link to a pdf file).

pdf_flag sub {
my $url = shift;
my $flag = 0;
if (index($url, '.pdf') > -1 or index($url, '.pdfe') > -1) {
$flag++;
}
return { pdf_flag => $flag };
}


Then calling it using:

<%if pdf_flag%>

how can we get the global to not include urls like: www.pdfreader.com which are currently included?

Also is there a gloabl that will return the total of two filed per link (Hits and Deatiled_Hits)?
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory

Last edited by:

katabd: Nov 6, 2008, 10:51 PM
Quote Reply
Re: [katabd] Global question In reply to
pdf_flag
Code:
sub {
my $flag = 0;
if ($_[0] =~ /\.pdfe?$/) {
$flag = 1;
}
return $flag;
}

..should do the trick

Call with

Code:
<%if pdf_flag($URL)%>....<%endif%>

Quote:
Also is there a gloabl that will return the total of two filed per link (Hits and Deatiled_Hits)?

Are you asking for a global to count both clicks and hits? You could probably just do that with a tag:

<%set TotalHits = $Hits + $Detailed_Hits%>
Overall hits: <%TotalHits%>

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!

Last edited by:

Andy: Nov 7, 2008, 1:12 AM
Quote Reply
Re: [Andy] Global question In reply to
That won't work as you expect. This will...

Code:
sub {
my $flag = 0;
if ($_[0] =~ /\.pdfe?$/) {
$flag = 1;
}
return { pdf_flag => $flag };
}
Quote Reply
Re: [Wychwood] Global question In reply to
Whoops, good point :P
Quote Reply
Re: [Wychwood] Global question In reply to
Still probably not a good idea to return a variable with the same name as the global itself. It should just return $flag instead.

Adrian
Quote Reply
Re: [brewt] Global question In reply to
Very true - didn't realise it was called the same thing (feeling a bit dosey this morning - self endulgued a bit too much last night at a fireworks party =))

I've updated the code (and way of invoking it) above.

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: [brewt] Global question In reply to
The global work great but only good for the pdfe file.. Can we include the pdfe and pdf files in the same global?
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] Global question In reply to
It should already do that due to...

e?


...which means the e is optional.