Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
      Just a general advice question more than anything, I need to create a website which links to a new web page, each has a unique picture and name such as something like this (http://www.molmovdb.org/cgi-bin/browse.cgi)

You don't give much to chew on with respect to why or what you are doing, but let me take a short in the dark on this:

In my view there isn't a single CPAN module that will address your needs. That said I'd recommend you look at both CGI (if you're not already familiar with it) and HTML::Template.

Consider the following mini-application:

#!/usr/bin/perl -w ################################## # Filename: albuum.cgi ################################## # use strict; use CGI; use HTML::Template; use DBI; my $dbh = (mumble..muble...); # Put your connection logic here my $q = CGI->new(); my $pic_id = $q->param('pic_id'); if ( $pic_id ) { my $sth = $dbh->prepare(qq( select picture_path from photo_album where picture_id = ? ) ) or die $dbh->errstr; $sth->execute($pic_id) or die $sth->errstr; my ($path)= $sth->fetchrow_array; my $tmpl = HTML::Template->new(filename=>'picture_page.tmpl'); $tmpl->param(picture_path=>$path); print $q->header(),$q->start_html(),$tmpl->output(),$q->end_html; exit(0); } else { my $tmpl = HTML::Template->new(filename=>"show_album.tmpl"); my $sth= $dbh->prepare(qq( select picture_id,title,path from photo_album order by title )) or die $dbh->errstr(); $sth->executre(); my @pictures =(); my $count=0; my $table_row = []; while (my $row=fetchrow_hashref){ push @$table_row,$row; $count++; if($count > 2){ $count=0; push @pictures,{row=>[$table_row]}; $table_row = []; } } my @check_row = @$table_row; if ((scalar @check_row) > 0 ) { my $add_cols = 3 - (scalar @check_row); for(my $i=1;$i<=$add_cols;$i++){ push @$table_row,{picture_id=>"",title=>"",path=>"" }; # bl +ank cell! } push @pictures,{row=>[$table_row]}; } $tmpl->param(thumbnails=>[@pictures]); print $q->start_html,$tmpl->@output,$q->end_html; } exit(0);
What this does is on entry to the application it goes to a database and queries for a list of your pictures and pulls in a template to produce HTML that displays a table of thumbnails. Here is your template code for that:
/** show_album.tmpl **/ <table width="100%" border="1" align="center"> <TMPL_LOOP NAME=thumbnails > <tr> <TMPL_LOOP NAME=row> <td> <TMPL_IF NAME=picture_id> <form action="/cgi-bin/album.cgi"> <hidden name="pic_id" value="<TMPL_VAR NAME=picture_id>"> <img src="<TMPL_VAR NAME=path>" width="75"><br> <submit name="action" value="Pic Me!"> </TMPL_IF> </td> </TMPL_LOOP> </tr> </TMPL_LOOP>
That will render a table of three cells per row with a thumbnail of the pictures in the album. Pressing the "Pic Me!" button beneath each picture will bring you to a page with the full sized picture.
/** picture_page.tmpl **/ <p> <a href="/cgi-bin/album.cgi">&lt;lt;Back</a> </p> <div style="width: 80%; border outset 3px black; margin: auto;"> <img src="<TMPL_VAR NAME=path" style="margin: auto;"> </div>
CAVEAT: This code was all written before I finished my first coffee and was not tested.


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

In reply to Re: Best Perl Module for creating multiple web pages with different information in them? by blue_cowdawg
in thread Best Perl Module for creating multiple web pages with different information in them? by fraizerangus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (8)
    As of 2018-06-18 18:23 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?



      Results (110 votes). Check out past polls.

      Notices?