Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Helpful mod

Quote Reply
Helpful mod
If you want to get HTTP environment variables into your web page...i.e $ENV{'HTTP_USER_AGENT'}

Do the following:

IN your HTML_Templates.pm
goto the sub that is printing the template page that you need an env var in.

I will use "site_html_search_form" as an example, as I needed to know if the user's browser was Explorer.

I added the following code in this sub:
my $MSIE;
if ($ENV{'HTTP_USER_AGENT'} =~ m/MSIE/){
$MSIE = "TRUE";
}else{
$MSIE = "";
}

I then changed:
print &load_template ('search.html', {
%$tags,
%globals
});

To read:
print &load_template ('search.html', {
MSIE => $MSIE,
%$tags,
%globals
});

Now I just add the following tags in my template:

<%if MSIE %>
Do something
<%endif%>

OR
<%ifnot MSIE %>
Do something
<%endif%>

Of course, you can call your var/tag something other than MSIE and get other environment variables too, like HTTP_REFERER

I used this cause my graphics line up in all browsers except for Explorer....figures Smile
Quote Reply
Re: Helpful mod In reply to
i modded my Template.pm to allow ENV variables..

so in templates i can put

<%if ENV{'HTTP_REFERER'} eq "something"%>

i'm too used to Links 2.0's site_html.pl and I don't like the change to templates Wink

jerry

Quote Reply
Re: Helpful mod In reply to
Oh yeah...forgot to mention that this only works for .cgi's that call the templates.
add.cgi, modify.cgi, etc.

It does NOT work for any pages that are built with the nph-build.cgi!!
Quote Reply
Re: Helpful mod In reply to
Hello!

Why not consider to put this in the resource?`

When someone does it something, nice, but it shines more in the resource forum.
Quote Reply
Re: Helpful mod In reply to
I agree...

There should be more quickies in the resource forum -- especially silly-template tricks <G>

My support time is very limited, which is why I'm waiting for the next release... once that happens I'll make sure my mods work on it and will start releasing them.

Right now there are 3 different versions out there, and with all the changes I've made, I'm not even sure any more which is what. I'm going to do a clean install and re-mod of the next version, so I'll know.

Quote Reply
Re: Helpful mod In reply to
I suggested to alex that he create a Links Sql mods category, but he hasnt made it yet, so I post them here.

Chris
Quote Reply
Re: Helpful mod In reply to
How come this never made the resource center. Are people not willing to add to the resource center for some reason?

------------------
James L. Murray
VirtueTech, Inc.
www.virtuetech.com


Quote Reply
Re: Helpful mod In reply to
cause we're not bored enough to go and submit a form.. i guess Smile

well at least i ain't.. Smile

jerry..

oops.. i lied Smile