Up and Running with Frontier Web Site Management
by Matt Neuburg
Author of the book Frontier: The Definitive Guide
A template is a frame into which every Web page is embedded when the page is rendered.Templates work hierarchically, like other directives. Thus, the template at websites.myFirstSite.#template, which was created automatically when you created myFirstSite, has been applied to "default" every time you rendered it. There's another template in the "websites" table, but it's further up the hierarchy, so myFirstSite.#template overrode it.
On the other hand, when you rendered samples.randomStuff, the template in the "websites" table was used, because websites.samples contained no template to override it.
Open websites.myFirstSite.#template. You see that it's an outline. A template does not have to be an outline; it can be a wptext, for example. But it is convenient for a template to be an outline just because outlines are such easy places to navigate and organize items.
This outline is a kind of minimalistic template; it does just what is required to turn your Web page into a legal HTML structure. It consists of three lines, each of which is interpreted in a special way by Frontier at rendering time. The first line is a command to create the opening HTML: the <html>, <head>, <title>, and <body> tags. The last line is a command to create the closing HTML, the </body> and </html> tags.
The middle line, which says "{bodytext}", is a pseudo-macro which represents the text of your Web page. So, your Web page ends up sandwiched between what the first line of the template generates and what the last line of the template generates.
This section is a little aside for people who want to be experts; you can skip it if it doesn't interest you.In order to understand what a pseudo-macro is, you need to know that the first and last line of this template are real macros. We'll learn what a macro is later on. The important thing to notice here is that the second line looks just like them -- it is surrounded with curly braces, which is the sign of a macro.
However, this particular expression, "{bodytext}", is normally handled by a completely different mechanism, called tag-substitution. The rendering engine just looks for the expression and substitutes the text of the Web page for it, directly.
This means that, because Frontier string searching is highly literalistic, you mustn't put "{bodyText}" or "{ bodytext }" -- whereas variations like that would be legal with a real macro.
Earlier versions of Frontier could use, instead of this pseudo-macro, either the pseudo-tag "<bodytext>" or the pseudo-tag "<meat>", which do still work. (I call them pseudo-tags because they look like HTML tags, but they aren't.) Another now largely disused pseudo-tag is "<title>", for which Frontier substitutes the value of the #title directive.
Every page will be embedded in a template (where the "{bodytext}" pseudo-macro is). So, if there is anything you would like to have appear before or after every Web page, the template is the place to put it.For instance, it is not uncommon to end a Web page with a mailto link to the webmaster, so that readers can get in touch if necessary. We already put a line that does this into "default", but if we want it to appear on every Web page, we don't want it in the individual pages but in the template.
Let's try it. Go into myFirstSite.default and delete the last lines (everything after "very easy" or "très simple" or however the last paragraph ends). Now go into myFirstSite.#template and create a line after the {bodytext} which refers the reader to the webmaster; perhaps you'd like a horizontal rule before that, so your template might end up looking something like this:
Now go back into myFirstSite.default -- actually, it is sufficient to select it in the myFirstSite table -- and preview it in the browser.
Isn't that pretty? The main text of what you're seeing came from "default", but the horizontal rule and what follows came from the template.
To assure yourself that this works as advertised, make a second Web page as a wptext in myFirstSite, calling it "secondPage" (without the quotes), and put something into it, such as:
#title "My Second Page" <p>My second page has some features of its own and some features in common with my Default page.</p>Preview that in the browser and you will see that your words tell the truth.
A question arises of how to designate a special template for just one Web page. Since a template is an outline (or a wptext), it cannot be placed into your Web page like a #bgcolor directive.One solution is a mechanism called "remote templates". You are permitted to place into a Web page a #template directive referring to a template living in user.html.templates. To see this in action, add a line to the start of "secondPage" that says this:
#template "example1"You'll see a bunch of error messages go by, and when you preview the page in the browser you'll see a lot of things that say "Macro error" (that's because the example1 template only works correctly for pages inside the davenet website), but the point is that this complete revamping of the arrangement of your page came from user.html.templates.example1.
Consider how much this template did. Look how different the formatting is from our earlier rendering of this same page. That's what templates can do.
You are free to store templates remotely in user.html.templates. However, the remote storage system is far less important than it once was, because of the hierarchical powers of directives.
If you wanted just one Web page to have a template of its own, another solution would be to make a subtable in your site table, and put into it just that page and its #template.
Some people don't like that solution, though -- it seems like a lot of trouble organizing tables and folders just for the sake of a single template -- and it doesn't solve the problem of two Web pages in disparate locations that need to share a template.
So here's a trick that lets a page use any template located anywhere in the database. In the page, you say (for example):
#template workspace.mySpecialTemplate #indirectTemplate falseNotice that there are no quotes around the template designation; and the #indirectTemplate directive must come after the #template directive. We're tricking the rendering engine here into doing something it isn't meant to do, but it works!
All text is by Matt Neuburg, phd, matt@tidbits.com.
For information about the book Frontier: The Definitive Guide, see my home page:
http://www.tidbits.com/matt
All text copyright Matt Neuburg, 1997 and 1998. ALL RIGHTS RESERVED.
No one else has any right to copy or reproduce in
any form, including electronic. You may download this material but you may not post it for others to
see or distribute it to others without explicit permission from the author.
Downloadable versions at http://www.ojai.net/matt/downloads/webTutorial.hqx and http://www.ojai.net/matt/downloads/webTutorial.zip.
Please do not confuse this tutorial with a certain other Frontier 5 tutorial based upon my earlier work.
This page created with
Frontier, 2/11/2000; 7:00:04 PM.