[ic] passing arg's w/o mv_arg (fwd)

Corey Gilmore interchange-users@lists.akopia.com
Wed Aug 8 18:49:01 2001


well since i got a relay error w/the orig send, i'll try again.

---------- Forwarded message ----------
Date: Wed, 8 Aug 2001 11:53:04 -0400 (EDT)
From: Corey Gilmore <cfg@dln.uvm.edu>
To: interchange-users@lists.akopia.com
Subject: passing arg's w/o mv_arg

Well, I ran into this problem a while back; i was using arguments for
keeping 'state' on my images in my menu's, but suddenly i needed to keep
state in two places, the section of my site you were in, and the section
of a sidebar you were in.  modifying mv_arg would have broken some of my
original code, so i wrote a little perl script to get around it.

I added this to catalog.cfg, and to interchange.cfg, I added 'pack' to the
SafeUntrap directive.

# return the query string
UserTag query_string Routine sub { return $CGI::query_string }

# pass the name of the argument you wish to get
# and it will pull it from the argument
# to find mv_conf_arg in HTTP_REFERER you would
# [get_dyn_arg name="mv_conf_arg" string="[query_string]"]

UserTag get_dyn_arg Interpolate
UserTag get_dyn_arg Order name string
UserTag get_dyn_arg Routine <<EOF
sub {
    my ($name, $buffer) = @_;
    my ($Value, $username, $Pair, %form);
    my @Buffer = split(/&/, $buffer);

    foreach $Pair (@Buffer){
         ($username,$Value) = split(/=/, $Pair);

     # Replace any special characters.
     $Value =~ tr/\+/ /;
     $Value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
     $username =~ tr/\+/ /;
     $username =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;

     # set our values
     $form{$username} = $Value;
    }
    return $form{ $name };
}
EOF


[query_string] would return the, well, query string passed to IC.
eg if you went to
http://my.domain.com/cgi-bin/IC/02PMS001.html?mv_arg=40&mv_pc=1406
it would return
mv_arg=40&mv_pc=1406

To implement the 'dynamic' arguments, things looked sort of like

[if scratch current_info_page == __ARG_SHOW_METHODS__]
<a href="[area href='[item-code].html' arg='[scratch cur_section]']&mv_conf_arg=__ARG_SHOW_METHODS__" class='bodylink'">
 <img SRC="__RIGHT_IMAGE_DIR__/register_a.gif" NAME="Register" BORDER=0 height=40 width=172 alt="Register">
</a>
[else]
<a href="[area href='[item-code].html' arg='[scratch cur_section]']&mv_conf_arg=__ARG_SHOW_METHODS__" class='bodylink' onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Register','','__RIGHT_IMAGE_DIR__/register_a.gif',1)">
 <img SRC="__RIGHT_IMAGE_DIR__/register_i.gif" NAME="Register" BORDER=0 height=40 width=172 alt="Register">
</a>
[/else][/if]

The main thing to notice is how the URL's are built.
<a href="[area href='[item-code].html' arg='[scratch cur_section]']&mv_conf_arg=__ARG_SHOW_METHODS__" class='bodylink'">
ignoring my silly little scratch variables, i just append
&mv_conf_arg=__ARG_SHOW_METHODS__
OUTSIDE of the [area] tag.

At the beginning of my page, I have
[set name=current_info_page interpolate=1][get_dyn_arg name="mv_conf_arg" string="[query_string]"][/set]

Where I pass the name of the argument I am looking for, and the string to
search in.



This is a fairly ugly hack, I'd be interested to see if someone has done
it another way.

.cfg
(reading his new IC 4.8 BOOKS!)