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
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