Templates

Matt Neuburg matt at tidbits.com
Tue Jul 17 11:28:33 PDT 2001


At 12:01 PM -0700 7/17/01, thus spake frontier-users-request at userland.com:

>From: Anthony Green <tony at rarepleasures.co.uk>
>To: <frontier-users at userland.com>
>Reply-To: Frontier-Users at userland.com
>
>I'm using Frontier 7.0 to generate the static HTML pages of my site
>www.rarepleasures.co.uk.
>
>The template uses 3 columns and on each page the content of the the three
>columns can change (or not) so the template is defined...
>
><td>{bodytext}</td>
><td>{html.processMacros (string (menu_m))}</td>
><td>{html.processMacros (string (menu_r))}</td>
>
>Then at the top of each page I define the directives thus:
>
>#menu_r "{html.processMacros (string (contact))}"
>#menu_m "{html.processMacros (string (competition))}"
>
>And in #tools I have the entries define
>
>Contact
>     contact details...
>
>Competition
>  This months competition...
>
>I was wondering if anyone had a more elegant solution.

You're working way too hard. :-) You are already processing macros, 
so you can just say:

<td>{bodytext}</td>
<td>{string (contact)}</td>
<td>{string (competition)}</td>

This use of macros as a straightforward substitution is quite common. 
If memory serves, I think it was Brian Hughes who made me realize how 
useful this could be.

>Also is it possible to store data in a custom table instead of #tools or
>#glossary

Absolutely. Frontier is a database. The whole idea is that you can 
grab stuff from a table. Just say its name and there you are. 
Basically you're just describing what Frontier is for. :-)


>
>How can I for instance create a table of biographies and still use the macro
>replace or glossary feature ?

If I were you I'd create a table of biographies and NOT use the 
glossary feature. I mean, why bother? You can just write a macro that 
grabs the right entry from the table. You *can* subvert the glossary 
feature to work in any way you like (there's a callback for this), 
but again I think you'd be working way too hard.

You have so wide a choice of architectures that it's difficult to 
know where to start. But suppose you had a table in #tools like this:

bios
   Ben Franklin
     blah blah blah
   Tom Jefferson
     blah blah blah

Then just saying {string (bios.["Ben Franklin"])} would slot the ben 
franklin bio into place. So then if you want to get really cool you 
can key the name of the bio to something else, such as a directive 
within the page. This could be simply be the title of the page, so 
you'd say {string (bios.[title])}, so the page titled "Ben Franklin" 
would automatically get the ben franklin bio, the page title "Tom 
Jefferson" would automatically get the tom jefferson bio, and so on. 
m.
-- 

matt neuburg, phd = matt at tidbits.com, http://www.tidbits.com/matt
Frontier Help Pages: http://drmatt.userland.com/
* The Book - Frontier:The Definitive Guide
      http://www.ora.com/catalog/frontier/index.html




More information about the Frontier-Users mailing list