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

How to start making a database driven website with separation of content from style.

by BioGeek (Hermit)
on Dec 02, 2004 at 14:14 UTC ( [id://411759]=perlquestion: print w/replies, xml ) Need Help??

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

Hi Monks,

I'm desiging my personal academic webpage, and since the new paradigma is the complete separation of content from style, I decided that's the way I will go.

What I want to achieve is an XML/XSL architecture similar to the one as explained on the Nun.Mu.Shu page. However, that site uses a Java/CoCoon/Tomcat/Xalan/Apache framework, whereas I would prefer a LAMP (Linux/Apache/MySQL/Perl) solution.

This has obviously be done before, but I have to admit that I've really lost my way in the forest of Template::Toolkit, HTML::Template, XML::LibXML, XML::LibXSLT, Petal, Maypole, CGI::Application and similar other modules. For the moment I don't see which one sticks with head and shoulders above the rest, or which one is extremely suited to my case.

So, what are my design briefs:
  • Pages in XHTML should be generated on the fly
  • I want to store my data as much as possible as flat file texts in a MySQL database
  • Part of my website is quite static (About me, CV, online presentation of my thesis), other parts should be dynamically served (blog, literature database, CGI frontend for a webapplication I wrote)

So, how do I start on this one?
  • Can you provide me with some step by step tutorials of how to proceed (first make a DTD? Or the XSLT,...?)
  • Given my design briefs, what module do you think is most appropriate? I don't need a fullblown ContentManagmentSystem with lots of whistles and bells, I've already decided on the layout and want to stick to that.


Hope you can point me in the rigth direction.
  • Comment on How to start making a database driven website with separation of content from style.

Replies are listed 'Best First'.
Re: How to start making a database driven website with separation of content from style.
by dragonchild (Archbishop) on Dec 02, 2004 at 14:18 UTC
    I personally wouldn't use XSLT for web-content. I'd look at CGI::Application, Class::DBI, and Template Toolkit. Everything you could ever want to do in a web-application-with-database can be done with those three modules.

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      Exactly. XSLT is just going to eat up a lot of your development time and makes things more complex than they need to be. Using something like CGI::Application (and HTML::Template if you do not like the Template Toolkit) will bring you results very quickly, while still producing maintainable applications with data management, logic and presentation cleanly separated.

      One thing you should not forget in the mix is CSS. You can greatly simplify your HTML output by putting all the styling into CSS. If you were looking at XSLT you should not have trouble to get the concepts here.

        The idea for using XSLT was that, if all the data of my thesis were stored in XML, then I could easily transform it into HTML pages or a .pdf/.ps/.doc/... document.

        But maybe that's indeed overkill.
Re: How to start making a database driven website with separation of content from style.
by gellyfish (Monsignor) on Dec 02, 2004 at 14:21 UTC

    If you are trying to weigh up the virtues of, say, TT vs XSLT you might be interested in looking at XSLT vs Templating, Part 2 where there are some quite diverse opinions in the matter expressed.

    /J\

Re: How to start making a database driven website with separation of content from style.
by perrin (Chancellor) on Dec 02, 2004 at 15:31 UTC
    Your requirements could fit just about any dynamic website on earth, so you're going to get a lot of "I like this" advice. However, if you really want to use XML, the major tool for XML sites in Perl is http://AxKit.org.
Re: How to start making a database driven website with separation of content from style.
by neniro (Priest) on Dec 02, 2004 at 14:57 UTC
    Using XSLT if you just wonna produce some XHTML-pages is kinda overkill. If you want to produce output for different kind of targets, it could be the right tool. But TT2 serves also well in this case.

    If you don't know where to start and which tool is the right one, you can ask youself which tool ist the one you can handle best. There is always a 'better' tool for the task, but this doesn't mean that it's a better tool for you.

    best regards,
    neniro

Re: How to start making a database driven website with separation of content from style.
by Taulmarill (Deacon) on Dec 02, 2004 at 15:00 UTC
    if you have a database and want to use TT2 i would recomend Maypole. i just don't see where XML would be needed.
Re: How to start making a database driven website with separation of content from style.
by Thilosophy (Curate) on Dec 03, 2004 at 02:51 UTC
    I want to store my data as much as possible as flat file texts in a MySQL database

    While you can store flat files as unstructured blobs in a database, if there is any structure in them, you should break the data up into "normal" tables with individual columns. Otherwise you will not be able to query this data in interesting ways, and a database is not giving you much over normal file system storage (except maybe easy remote accessiblity, but do you need that?).

    Part of my website is quite static (About me, CV, online presentation of my thesis), other parts should be dynamically served (blog, literature database, CGI frontend for a webapplication I wrote)

    I do not think you have to consider static rendering unless

    • dynamic pages are not a option on the server (not a problem in your case)
    • dynamic pages generate too much load on the server (could happen if you have a lot of traffic)
    Otherwise, managing static pages is not worth the extra head-ache. You have that CPU, so use it.
    Of course, you have to be able to produce any given page in less than, say, three seconds. But if, for example, a page needs data that takes more than that to produce, you should periodically refresh a cache with that data and produce a dynamic HTML page from that (static) data, instead of producing a completely static HTML page. Once you have all the data for your page, formatting it into HTML is not going to take any significant amount of time.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-04-19 10:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found