[ic] Specify flypage using javascript or another non-database method

DB db at m-and-d.com
Thu Jun 25 01:12:38 UTC 2015


>> Hi all. I'm working an making IC5 site a bit more mobile friendly and so
>> far it's been fairly painless. Using javascript to redirect mobile
>> visitors to the mobile version of a page works well. But I now need a
>> way to make mobile visitors see a different flypage than non-mobile
>> visitors see.
>> 
>> PageSelectField looks like one way to change the flypage on a
>> per-product basis but that's not what I need here. Can anyone think of a
>> way to change the flypage using javascript or ome other non-database
>> method? Thanks for any ideas!
> 
> Surely you can detect the presence of a mobile browser? If so,
> you can easily do:
> 
> Sub change_fp <<EOR
> sub {
> 	return unless $Tag->is_mobile();
> 	$Config->{SpecialPage}->{flypage} = 'mflypage';
> 	return;
> }
> EOR
> 
> Autoload change_fp
> 
> -- 
> Mike Heins
> Perusion -- Expert Interchange Consulting    http://www.perusion.com/
> phone +1.765.253.4194  <mike at perusion.com>

I got around to trying this finally. In my global directory I created
is_mobile.tag containing:

UserTag is_mobile hasEndTag
UserTag is_mobile Routine <<EOR
use HTTP::BrowserDetect;
sub {
        if(! defined $Vend::Session->{mobile_browser}) {
                my $ua =
HTTP::BrowserDetect->new($Vend::Session->{browser});
                if($ua->mobile()) {
                         $Vend::Session->{mobile_browser} = 1;
                }
                else {
                         $Vend::Session->{mobile_browser} = 0;
                }
        }

        return $Vend::Session->{mobile_browser}
                ? Vend::Interpolate::pull_if(shift (@_))
                : Vend::Interpolate::pull_else(shift (@_) );
}
EOR


and then in my catalog.cfg I added:

Sub change_fp <<EOR
sub {
       return unless $Tag->is_mobile();
       $Config->{SpecialPage}->{flypage} = 'mflypage';
       return;
}
EOR

Autoload change_fp

I restarted IC and it squawked about HTTP::BrowserDetect missing, so I
installed that using yum. But now in my catalog error log I get:

CAT /cgi-bin/CAT/index.html Died in server spawn: Can't locate object
method "mobile" via package "HTTP::BrowserDetect" at (eval 500) line 5.

Maybe the version of HTTP::BrowserDetect that yum (Centos 5) installed
is too old? Any other thoughts?

DB




More information about the interchange-users mailing list