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

I have a collection of cd with movies. I'd like to have an Overview, so I am planning to have an apache "movie-server" which offers information about the movies I have. I imagine, that it shows an index in the left navigation frame and if you select one, the picture and the text appears in the right mainframe to the client, which can be any computer in my intranet. The server should store pictures in a subdirectory and the texts in a mysql datatable. An admin interface to put new pictures and text into the system would be fine, too.

As this is a simple structure, I'd like to use templates or XML (which I have no experience of). I'd appreciate to get tips, how to create this.

I am used to write cgi-stuff with CGI.pm but I am new to templates, so give me your experience, please. An example which is similar to my belongings would be great.
--
there are no silly questions
killerhippy

  • Comment on Movie-database (mysql) with browser interface

Replies are listed 'Best First'.
Re: Movie-database (mysql) with browser interface
by MZSanford (Curate) on Oct 19, 2001 at 17:12 UTC
    I have written similar things, and on a small scale i find HTML::Template to work very well. Now, if it is of larger scale, maybe HTML::Mason, or one of the many other Template systems will be needed.

    I understand that holding the data in the database in XML format will give you more flexability, and i suggest the always good XML::Writer and XML::Parser for all of your XML needs. I do implore you though, please spend as much time as you can on the XML design, because if you do not, all of the flexability that XML promisses in this buzzword-tastic world will be lost.

    Other than that, i will not post a complete template/DBI/CGI solution here, but would feel better if you use the information above to make an educated decision when start to write the code.

    my $two = $euro/100;
    i had a memory leak once, and it ruined my favorite shirt.
Re: Movie-database (mysql) with browser interface
by Masem (Monsignor) on Oct 19, 2001 at 17:20 UTC
    You'll want to take a look at the various template modules, HTML::Template, HTML::Mason, or Template Toolkit 2, to name the more popular ones.

    In nearly all cases, all you need to do is use normal CGI programming, then load up a hash with values that you got from your mysql database; this hash is then passed to the template module, which fills in the template form, and either prints it to STDOUT or returns it as a string after which you can print it out to whereever. For example, with TT2, you could call your template as such:

    print $tt2obj->process( 'mytemplate.html', { title => 'Matrix', image => 'matrix_cover.jpg', desc => 'This is a cool movie with CGI effects' } );
    and then in 'mytemplate.html', you'd have placeholders as such:
    <H2>[% title %]</H2> <IMG SRC="[% image %]" alt="[% title %]"> <P> [% desc %] </P>
    The various template solutions allow for much more control of the output and allow for looping and if-then constructs as well.

    -----------------------------------------------------
    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
    "I can see my house from here!"
    It's not what you know, but knowing how to find it if you don't know that's important

Re: Movie-database (mysql) with browser interface
by CubicSpline (Friar) on Oct 19, 2001 at 17:17 UTC
    Hi khippy! I've done the same sort of thing for pictures that we take on our digital camera. Sort of an online photo album.

    The one thing that I would like to say is to not lock yourself into a technology to implement this. Do you want to use XML because you think that's the best way to approach this problem, or because you just want to learn something new? Either one is a fine reason, but I think it bears thinking about before you get yourself buried in implementation.

    If you know exactly what you want to do and how it should look and you have an idea of how to do it with straight HTML and CGI.pm, then I would just go that route. There is definitely something to be said for choosing the right tool for the job.

    ~CS

      Hi CubicSpline,

      thank you for your answer. Indeed, you are right that I can write a cgi managing this, because it is so simple. That would also be the fastes way to get it done, too. So it seems to be the most wining solution, ...but, and now you are right, too, I'd like to enrich my capabilities, too.

      So I am intersted in learning XML, which I have often heard of, but don't know how to use. I was wondering, if this small project would be right to get it done and learn XML, too.


      --
      there are no silly questions
      killerhippy
        Seems like a little overkill, but you might have good luck with AxKit. I'm planning to delve more deeply into it soon. (That link may not work at the moment. There's been a bit of domain trouble lately.)