Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: Re: Alternatives to PerlTransHandler?

by kwoff (Friar)
on Nov 02, 2001 at 06:12 UTC ( [id://122740]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Alternatives to PerlTransHandler?
in thread Alternatives to PerlTransHandler?

I see, so it is per-user skinnable. Those links you gave use cookies. If that's acceptable, then I offer the following solution (only tried on Mozilla). It sets a cookie, then uses a Server-side includes to choose which skin to display. The sample CGI script uses CGI.pm. It's not the best solution I guess, but it's somewhat amusing at least. :)

ssi-cookie.html

<HTML> <BODY> <A HREF="/cgi-bin/skin-cookie.pl">Skin this</A><BR> <!--#if expr="${HTTP_COOKIE} = /skin\=wacky/"--> wacky <!--#elif expr="${HTTP_COOKIE} = /skin\=goth/"--> goth <!--#else --> minimal <!--#endif --> </BODY> </HTML>

/cgi-bin/skin-cookie.pl

#!/usr/local/bin/perl -Tw # set 'skin' cookie then redirect where we came from use strict; use CGI; use vars qw($q $cookie $location $status @skin_names); $q = new CGI; @skin_names = qw(minimal wacky goth); main(); sub main { if (defined $q->param('skin')) { # user selected a skin my $skin_param = $q->param('skin'); for my $valid_skin (@skin_names) { if ($skin_param eq $valid_skin) { skin_cookie_page($skin_param); } } # fall through if invalid } pick_skin_page(); } sub get_old_url { return $q->param('old_url') || $q->referer() || 'http://perlmonks.org/'; } sub skin_cookie_page { my $skin_param = shift; my $cookie = $q->cookie( -name => 'skin', -value => $skin_param, -expires => '+30d', ); print $q->header(-cookie => $cookie, -status => '302 Moved', -location => get_old_url()); exit; } sub pick_skin_page { print $q->header(), $q->start_html(), # you'll want to skin this too, natural +ly :) $q->start_form(), 'Choose your skin: ', $q->popup_menu(-name => 'skin', '-values' => \@skin_names) +, $q->submit('skin'), $q->hidden('old_url' => get_old_url()), $q->end_form(), $q->end_html(); exit; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://122740]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 14:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found