Jesse, Folks Below is an old message Jesse sent to the list detailing how to get the run mode from the PATH_INFO variable. I used this as part of Cascade ( http://summersault.com/software/cascade ) and found it to be an excellent solution. I ended up creating a method "get_mode_param" which does what you describe: # %FORM = CGI param environment here. # use the first piece of PATH_INFO, or just look in $FORM{rm}; sub get_mode_param { my $pi = $ENV{PATH_INFO}; # remove the leading slash $pi =~ s!^/!!; # just grab the first field $pi = (split q!/!, $pi)[0]; $FORM{rm} = (length $pi) ? $pi : $FORM{rm}; } ############### I'm interested in having an option to turn on this sort of PATH_INFO parsing built-in to CGI::Application. I'm sure you probably have in mind a way this could be implemented without using Nasty Globals like I did, though. :) Have other folks tried getting the run mode from PATH_INFO? What did you think of it? Like Jesse I like it because it's spiderable, but most significantly for the useful way it seperates the run mode from the rest of the form data. Thanks, -mark Jesse Erlbaum wrote: > > > This configuration gives me the best of both worlds. I have created > > > bookmark-able, and spider-able "public" run-modes, yet I > > have retained my > > > ability to develop normally using form parameters. I'd be > > happy to post a > > > code sample, if anyone is having trouble imagining how the > > setup() method > > > for this would be written. .... > > Here is a setup() method I made for an application which uses > $ENV{PATH_INFO} to automatically set the run-mode. This application is for > a website I developed long, long ago for a friend, but this application was > done fairly recently. My friend runs a niche music retail website. The > sole purpose of this application is to enhance his profile in the search > engines by creating spider-able URLs which contain the bulk of the content > of his database. You can view the running application at the following URL: > > Index View: > * http://www.middlepillar.com/catalog/browse.pl/index/ > > ...Also, try: > * http://www.middlepillar.com/catalog/browse.pl/index/A/ > * http://www.middlepillar.com/catalog/browse.pl/index/B/ > * http://www.middlepillar.com/catalog/browse.pl/index/C/ > > Try the Artist run-mode: > * http://www.middlepillar.com/catalog/browse.pl/artist/BIRTHDAY_PARTY/ > * > http://www.middlepillar.com/catalog/browse.pl/artist/CAVE__NICK_%26_THE_BAD_ > SEEDS/ > > The first PATH_INFO element is what I use for the run-mode. I pass along > the others to be used within each run-mode, as it sees fit. That is what > $self->param('PATHS') is used for. > > Note that if the user has requested a URI without a trailing "/", I redirect > them to the same URI with a "/" at the end. > > sub setup { > my $self = shift; > > my $pi_raw = $ENV{PATH_INFO} || ''; > > if ($pi_raw =~ /\/$/) { > $pi_raw =~ s/^\///; > my @paths = split(/\//, $pi_raw); > $self->param('PATHS', \@paths); > $self->start_mode( (shift(@paths) || 'menu') ); > } else { > $self->param('REDIRECT_URL', $ENV{REQUEST_URI} . '/'); > $self->start_mode('redirect'); > } > > $self->run_modes( > 'redirect' => \&redirect, > 'menu' => \&menu, > 'index' => \&index, > 'artist' => \&artist, > ); > > $self->tmpl_path('Catalog/BrowseArtists/'); > } > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
