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

CGI::Application Question

by debiandude (Scribe)
on May 19, 2003 at 01:51 UTC ( [id://259038]=perlquestion: print w/replies, xml ) Need Help??

debiandude has asked for the wisdom of the Perl Monks concerning the following question:

I'm reding my site using HTML TEMPLATE and CGI::APPLICATION so I can use a common code within all my sites. Anyway here is my question:

index.pl is the script that calls everything. Its has several run modes, articles, admin, and home.

By default it lodes up home.

Now if I want to display the articles I would use this: index.pl?node=articles

However I want to specify a specific article, so I would like it to recognize this:

index.pl?node=articles?15

And goto the 15th article.

This is what the setup function looks like:


sub setup { my $self = shift; $self->run_modes( 'home' => 'home', 'articles' => 'articles', 'admin' => 'admin', ); $self->param('dbh' => DBI->connect( "DBI:mysql:tro:localhost", "root", "", {RaiseError => 1}) ); $self->tmpl_path('/var/www/petnuch/html_templates'); $self->start_mode('home'); $self->mode_param('node'); }

Thanks for any help.

Replies are listed 'Best First'.
Re: CGI::Application Question
by elusion (Curate) on May 19, 2003 at 02:22 UTC
    The easiest way to do this would be to add another parameter to the query string. In other words, request "index.pl?node=articles&n=15" or something like it. Then...
    sub articles { my ($self) = @_; my $q = $self->query; # CGI query object my $n = $q->param('n'); # get article number ... # get and display the nth article }
    Hope this helps,

    elusion : http://matt.diephouse.com

      Wow thanks. That worked right away.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-26 08:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found