[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
Re: [ic] Redisplaying the current page for change of locale
Quoting icottee@bluefountain.com (icottee@bluefountain.com):
> I've received some help with this on the irc chat channel but I
> thought I'd post here to see if anybody else has any insight. I have a
> site with three languages and three currencies. The options to change
> language and currency are situated are located on the left
> navigator. These set the necessary information and then take the user
> to the front page using (for example)
>
> [page process/locale/ja_JP/page/index]Jpn[/page]
>
> Now what I would like to do is redisplay the current page instead of
> taking the user back to the front. I could use @@mv_page@@ but if (for
> example) I am displaying a search result I just get results.html
> back. Same issue with pages displayed with flypage.html
>
> Anybody does this sort of thing or can suggest a way to get the
> current URL and force the locale change using it?
>
The only real way is to use the History, but even that is not
perfect. Remember that you cannot always recreate things from
a URL when you have sessions and the Scratch area.
Try enabling history in catalog.cfg:
History 10
Then look at the History key in the session:
'History' => [
[
undef,
{
'mv_nextpage' => 'index',
'mv_session_id' => 'zGxJyFMi',
'mv_username' => undef
}
],
[
'/scan/st=db/co=yes/sf=category/se=CPU chips/va=link_image=/va=link_banner=.html',
{
'mv_nextpage' => 'results',
'mv_session_id' => 'zGxJyFMi',
'mv_username' => undef
}
],
[
'/scan/st=db/co=yes/sf=category/se=Motherboards/va=link_image=/va=link_banner=.html',
{
'mv_nextpage' => 'results',
'mv_session_id' => 'zGxJyFMi',
'mv_username' => undef
}
],
[
'/dump',
{
'mv_nextpage' => 'dump',
'mv_session_id' => 'zGxJyFMi',
'mv_username' => undef
}
]
]
}
You can recreate URLS with something like:
[loop list="en_US ja_JP"]
<A HREF="[loop-calc]
my $hist;
my $locale_string = 'process/locale/[loop-code]/page';
my $current;
$current = 1 if ! $Session->{History};
$current = 1 unless $hist = $Session->{History}->[-1];
my ($path, $parm_hash) = @$hist;
$current = 1 if $path eq 'expired';
return $Tag->area( $locale_string . '/@@MV_PAGE@@')
if $current;
# Prevent successive locale strings from causing error...
$path =~ s{^/process/locale/\w+/page}{};
$path = $locale_string . $path;
my @parms;
foreach my $var (keys %$parm_hash) {
my $val = $parm_hash->{$var};
push @parms, "$var=$val";
}
my $form = undef;
if(@parms) {
$form = join "\n", @parms;
}
return $Tag->area( { href => $path, form => $form || undef } );
[/loop-calc]">[loop-code]</A>
[/loop]
It wouldn't be too hard to build a usertag out of this....but the locale
stuff is pretty custom depending on how you do it. Good one for a user
contribution.
--
Akopia, Inc., 131 Willow Lane, Floor 2, Oxford, OH 45056
phone +1.513.523.7621 fax 7501 <heins@akopia.com>
My wife is great. She doesn't care where I go, just as long as I don't
have any fun. -- Lee Trevino
_______________________________________________
Interchange-users mailing list
Interchange-users@lists.akopia.com
http://lists.akopia.com/mailman/listinfo/interchange-users