[ic] prepend to PageSelectField

Mike Heins interchange-users@icdevgroup.org
Tue Dec 24 13:21:01 2002


Quoting Paul Jordan (paul@gishnetwork.com):
> Hi List
> 
> 4.9.4 (Mysql) Right now I use in catalog.cfg:
> 
> PageSelectField    prod_group
> 
> I am trying to do somehting like:
> 
> PageSelectField  <<EOR
> sub {
>    my $fly = $Tag->field(prod_group);
>    my $newfly =~ "f_" . "$fly";
>    return $newfly;
> }
> EOR
> 
> So if prod_group was let's say 'image' then it would look for the
> flypage 'f_image'
> 
> Does anyone know if it is possible to prepend a value to
> PageSelectField? I need to prepend 'f_' for several reasons. My above
> attempt(s) have been fruitless. I only assume something like the above
> was possible... if someone could point me in the direction of how to go
> about this, I am sure I culd figure out the rest.
> 

The normal method is to use the "template" field in products to
maintain a separate template field and not base it on prod_group.
Then you just set "PageSelectField template".

If you really want to go to all the trouble not to do that, you
can try using Tie::Watch on the "SpecialPage" directive -- but
that way lies madness. (See icconfig "Programming Watch Points"
if you are a masochist and want to try that.)

There would be another way, via GlobalSub and Autoload. You just check
the path for a valid product code, and set
$Vend::Cfg->{Special}{flypage} accordingly when you find one.

GlobalSub <<EOR
sub munge_flypage {
	my $code = $Vend::FinalPath;
	$code =~ s/\.html?$//;
	$code =~ s:^/::;
	my $db = Vend::Data::product_code_exists_ref($code)
		or return;
	my $template = $db->field($code, $Vend::Cfg->{PageSelectField})
		or return;
	$Vend::Cfg->{Special}{flypage} = "f_$template";
}
EOS

Then in catalog.cfg you put "Autoload munge_flypage".

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.513.523.7621      <mike@perusion.com>

I don't want to get to the end of my life and find I have just
lived the length of it. I want to have lived the width of it as
well. -- Diane Ackerman