Matthew,
Sample config is attached.
As background:
With some minor edits, this config file is what I've been using for
testing purposes.
Why XML as a config-file format? I had been getting frustrated with
traditional .ini-style config limitations, and XML provided an easy
solution. Besides, using <!-- --> to comment out regions becomes
extremely helpful when debugging.
What's happening here?
The <database> section contains connection information - as you see,
password is currently commented out, as an example of the above, since my
dev box happens to not require a DB password ;-).
There can be an arbitrary number of <query>'s in a config file. Each
<query> set is made up of a <main_query> (SQL that returns the bulk of the
data), potentially <sub_query>'s, and <templates>s for output.
The general idea is that each row of data that returns in a <main_query>
corresponds to a row of output - either a row in the 'listing page'
template, or an explicit page in the 'details page' template.
Each restaurant can have an arbitrary number of cuisines & addresses -
this is why these queries are split out into <sub_query> entries - if they
were part of the <main_query>, the DB would return multiple rows of data
for each restaurant - which breaks output. By using <sub_query>, the
cuisines & addresses are handled in the output templates as <TMPL_LOOP
NAME="cusine"> and <TMPL_LOOP NAME="address"> loops.
All ${name} entries in the config correspond to columns returned in
<main_query> - with the exception of ${PAGE_NUM}, which is handled
internally.
The result?
./details/restaurants/restaurant1.htm
is the first listing page, containing quick summaries & URL links to the
details pages for up to 25 restaurants. If there are more than 25
restaurants,
./details/restaurants/restaurant2.htm
Is written out, and so on. PREV and NEXT variables are populated with the
URLs for previous and subsuquent listing pages, as they exist. It's up to
the template writer to check these variables to see if links back & forth
exist.
All the details pages are written out based on their venue_id, e.g.
./details/restaurants/15.htm
./details/restaurants/16.htm
./details/restaurants/17.htm
Believe it or not, this is a fairly simple config file. Since you can
support any number of query/template sets, one config file is usually
sufficient for an entire site.
Further questions/input greatly appreciated - I'm hoping to put this up in
the next few weeks, once the internal code has been removed.
thanks,
--peter
On Tue, 9 Apr 2002, Hicks, Matthew wrote:
> Could you send me an example config snippet? --Matt
>
> -----Original Message-----
> From: Pete Leonard [mailto:[EMAIL PROTECTED]]
> Sent: Monday, April 08, 2002 6:10 PM
> To: Hicks, Matthew
> Subject: RE: [htmltmpl] Question - product interest + naming help?
>
>
>
> The config file is offline - contains DB connection info, queries,
> templates associated with each query, output info, etc..
>
> I actually have a module that can be used to build the config files, but
> it's fairly low-level - some custom code would be needed to interface with
> CGI::Application.
>
> --pete
>
>
> On Tue, 9 Apr 2002, Hicks, Matthew wrote:
>
> > What's the config file look like? Is the result an interactive page that
> > uses CGI::Application, too (data into the DB as well as data out)? Or is
> it
> > just 'report' functionality out of the DB (just data out)?
> >
> > --Matt
> >
> > -----Original Message-----
> > From: Pete Leonard [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, April 08, 2002 5:35 PM
> > To: [EMAIL PROTECTED]
> > Subject: [htmltmpl] Question - product interest + naming help?
> >
> >
> > Hi everyone,
> >
> > I've got a software project I've been working on for the last year or so
> > that I (and my employer -- coincidentally, Sam's emplyer too) would like
> > to open-source.
> >
> > Like most perl projects, it takes DB content, HTML templates, a config
> > file, and generates output. In this case, the motivation was that we
> > needed a cheap 90% solution to wean a number of clients off of expensive
> > proprietary first-generation CMS systems that couldn't handle heavier
> > traffic loads.
> >
> > We've used this system for about a year now, and it's been a success. As
> > it builds out static HTML content offline, webserver costs have gone down
> > dramatically, as have DB costs. It has also scaled fairly well,
> > supporting sites with anywhere from 1,000 to 1,000,000 pages of content.
> >
> > HTML::Template::Expr is the templating engine behind all of this (thanks,
> > Sam!).
> >
> > Is there interest out there in a project such as this?
> >
> > Furthermore, does anyone have any suggestions on a name? The current one
> > is a guaranteed lawsuit in a public forum, and besides, it's not all that
> > great a name anyways.
> >
> > All input greatly appreciated.
> >
> > thanks,
> >
> > --pete
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
<?xml version="1.0" standalone="yes"?>
<document>
<site_name>LocalRestaurants.com</site_name>
<database>
<name>localrestaurants</name>
<host>localhost</host>
<type>Pg</type>
<user>dbuser</user>
<!-- <db_pass>abcde</db_pass> -->
</database>
<query name="restaurants">
<main_query>
SELECT *
FROM search_restaurant_view
ORDER BY venue_name
</main_query>
<sub_query name="address" column="has_multiple_addresses" value="1">select * from
address_view where venue_id=${venue_id} order by venue_id</sub_query>
<sub_query name="cuisine" column="has_cuisine">select venue_type_feature_value_name
as cuisine from feature_view where venue_feature_code = 'CUI' and venue_id=${venue_id}
order by venue_id</sub_query>
<template name="listing_page" type="ncf" prevnext="inside" position="1">
<filename>templates/restaurants.htm</filename>
<url>http://localrestaurants.com/details/restaurants/restaurant${PAGE_NUM}.htm</url>
<output_filename>./details/restaurants/restaurant${PAGE_NUM}.htm</output_filename>
<items_per_page>25</items_per_page>
</template>
<template name="details_page" type="ncf" position="2">
<filename>templates/restaurants_details.htm</filename>
<url>http://localrestaurants.com/details/restaurants/${venue_id}.htm</url>
<output_filename>./details/restaurants/${venue_id}.htm</output_filename>
<summary name="title">${venue_name}</summary>
<summary name="description">${short_writeup}</summary>
</template>
</query>
</document>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]