The Metadata Plugin
Metadata Management for Manila
 
Site last updated
2/24/2006; 12:33:21 PM
 
Home

Why

Features

FAQ

Updates

Documentation

Download

Developers

Bugs

Feedback

Discuss

Planned
Features

 
 

Multiple Templates and Subtemplates in Manila

Here's how to implement subtemplates and multiple templates in Manila. The technique is the same for both. This assumes you have the Metadata Plugin 1.5 or later installed. Important: if you have just updated to version 1.5, you must disable, then enable the plugin. This updates the pageFilter architecture.

First, we need to set up a meta type that will be your Template Selector. All this means is that we're going to add a column to our website that will denote which template will be used. Here's the way our website might look before:

MsgNum Subject               PostedBy        When
------ --------------------- --------------- -------------------
   1   How to frisk a cat    mo@zzzzzzz.com  5/16/00; 3:39:24 PM
   2   Getting rid of fleas  mo@zzzzzzz.com  5/16/00; 3:42:10 PM
   3   Shedding on the rug   mo@zzzzzzz.com  5/16/00; 3:55:33 PM

and here's how it would look after:

MsgNum Subject               PostedBy        When                 Template
------ --------------------- --------------- -------------------  ------------
1 How to frisk a cat mo@zzzzzzz.com 5/16/00; 3:39:24 PM How-To 2 Getting rid of fleas mo@zzzzzzz.com 5/16/00; 3:42:10 PM How-To 3 Shedding on the rug mo@zzzzzzz.com 5/16/00; 3:55:33 PM Default

If you need a refresher on these concepts, reread Why the Metadata Plugin is Important

Anyway, I like to call my Template meta type Template or Section. That way I don't get confused.

Now I have to decide which templates I'm going to create. In this example we're only going to create one new template, but you may create as many as you like.

I already have a template -- the default template for my Manila site. I could edit it in the normal way, by clicking on Prefs --> Advanced.

But now it's time to create a new template. I'm going to call it How-To and on this cat site I'll create a special logo with a smart-looking cat that will appear only in the How-To template. Or maybe I'll just change the font color.

The first thing I do is to log in as Managing Editor. This gives me my Editors Only menu. I click on metaData to reach the Manage Meta Types page (if metaData is not an option, you probably don't have the Metadata Plugin installed or enabled. See this page.)

If I haven't created the meta type named Section or Template, now is when I would do it. I actually prefer to use Section instead of Template because it's a more comfortable idea. Rather than thinking about a page being assigned a template, I like to think of which section of the site the page is in, and as a corollary: that section has a template. You can then dual-purpose that meta type by using it to build your site index (see "How to Create an Automatic Site Index"), use "The showrelated() Macro", etc.

So I've created my Section meta type. It looks like this:

Section Metatype Screenshot:

Options Screenshot:
Now I want to add some values to this meta type. So I click on the Index Maintenance link. I then choose Section as the meta type I want to work with, choose How-To as the value I wish to add, and I click the Add button.

Add Section Value Screenshot:

The resulting page says "Entry for Section = How-To added", so I know it worked. If you've ever set up value lists in FileMaker pro, this is the same type of procedure.

Now I go back to my Manage Meta Types page because I'm ready to edit my new template.

Notice that at the bottom of the Manage Meta Types page, under Options, is an option called Multiple Templates. Click on it.

It asks me which template I want to use as my Template Selector. Of course, I want to use Section...that's why I created it. I'm also going to create a new template called How-To. Notice that the name of the template is the same as the value I just added to the index for Section. They must be the same because that's how the Metadata Plugin figures out which template to use.

Create Template Screenshot:

Now my new template is listed, and I can click on its name to edit the actual template:

Template Listed Screenshot:

When I click on the name of the template, I get a standard textarea field that I can edit to my heart's content. Or I could paste in a template I created in DreamWeaver, or whatever.

Notes on templates:

  • Your template must contain the {bodytext} macro, obviously, or nothing will get inserted into the template.
  • If your template does not contain an <html> tag, the template will be placed inside your standard Manila template. This is called subtemplating. When this happens, your template gets inserted where the {bodytext} macro is in your standard Manila template. Since your template also contains a {bodytext} macro, all we're really doing when we subtemplate is adding a standard chunk of HTML to the standard template. This can be quite useful. For example, suppose you want to keep the navigation bar the same but change the column width of a table. I'm sure you'll think up some great uses for this. It's powerful!
  • If your template does contain an <html> tag, the standard Manila template will not be used at all. Instead, your template will be used.
  • If the value of the meta type you have selected to use as a Template Selector does not match any template name, the standard Manila template will be used. In other words, an easy way to say "just use the standard template" is to create a value but don't create the corresponding template.

For this example, I just want to make all the text on the page red. So my How-To template looks like this:

<font color="red">{bodytext}</font>

Now when I'm editing a page in Manila and I choose How-To for the Section meta type, like this,

Shedding Edit Screenshot:

the resulting page uses my template, and the text is annoyingly red:

Shedding Red Screenshot:

Have fun!

Comments...


This page last updated Wednesday, September 6, 2000 at 5:02:42 PM. (7389)