[ic] Re: Making flypage based on fields other than sku

Ron Phipps ron at endpoint.com
Tue Sep 19 16:01:44 EDT 2006

Oleg Raskin wrote:
>> Hi, Oleg!
>> There are probably many ways to do this in Interchange. You could do
>> something like that using an ActionMap. Say you call it 'details'. Then
>> you could call 'mystore.com/details/Hand_Brush.html.
>> Very roughly, and untested:
>> ActionMap details	<<EOR
>> sub {
>>   my $target = shift;
>>   my $sku = $Tag->data({
>>     table => 'products',
>>     field => 'sku',
>>     foreign => 'custom_field_of_your_choice',
>>     key => $target,
>>   });
>>   # Store the target in $Session->{arg}
>>   $Session->{arg} = $sku;
>>   # Set the target page
>>   $CGI->{mv_nextpage} = 'flypage.html';
>>   return 1;
>> }
>> EOR
>> HTH,
>> JT
> Thanks for the quick response, that's an interesting solution.  The
> problem is that it actually makes the URLs longer with the extra
> directory, which is exactly what I am trying to avoid.  The reason I am
> trying to make the URLs more meaningful in the first place is for search
> engine relevance, so I'd like to keep them as short as possible.
> Would there be a way to accomplish that?

I did something like this to convert old urls for products to new urls, it may help you out:

## Map a subroutine to happen if the page is not there
SpecialSub  missing  ncheck_sku

Sub ncheck_sku <<EOS
sub {
    my ($name) = @_;
    return unless $name =~ m/^(\w)+-([A-Za-z0-9-])+$/;
    my $bounce = $Tag->lookup_sku($name);        

    if (! $bounce) {

    $CGI->{iid} = $bounce;
    return (1, 'flypage');

This runs anytime a page is not found in IC.

My lookup_sku usertag checks if the page name passed is a valid sku for the old urls and if it is it returns the new sku and that is set in iid.  The flypage uses the iid to determine which product to show, otherwise it shows the missing page as normal.

You'll need to update it to do what you want but this should get you started.  You won't need the regex to check if it's in the sku format, since you'll be passing titles.  Your lookup_sku could return the sku for a given title.  You'll also need to pass the sku back in $Session->{arg} unless your flypage makes use of a cgi variable.

You could even have your lookup_sku function convert the passed url to take out the underlines and replace them with spaces and then compare it against the title field of the product, then you wouldn't need a special field.

After you do all this you'll need to come up with a tag to generate product links and use that throughout your site whenever you want to link to a product.  This tag could take the title and convert it to a safe url, or use the value in your custom field.

Lastly if you don't mind having the url be one directory deep you can update JT's code to be directory /p/ instead of /details/.

Ron Phipps
End Point Corporation
ron at endpoint.com

More information about the interchange-users mailing list