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

 
 

Create an Automatic Site Index with the Metadata Plugin

Author:   John VanDyk  
Posted: 7/29/2000; 9:11:42 PM
Topic: Create an Automatic Site Index with the Metadata Plugin
Msg #: 197 (top msg in thread)
Prev/Next: 196/198
Reads: 10078

You want a site index or site map on your site. That way users can quickly find what they want.

But site indices are a pain. Every time you update a page or add a new page to a section, you have to update it in the site index. Wouldn't it be nice if the site index updated itself automatically when you added a page? Here's how to get that functionality.

First, you'll need to add a meta type to identify the sections of your site (if you don't know how to do this, it's easy -- see the Managing Meta Types page for details). You may already be doing this for other purposes, such as using multiple templates within a site.

Anyway, I like to call my section metatype Section. When I'm creating the first page on the site, I use the regular text field format for the meta type so I can just type in the name of the section. After that, I change the field format to Dropbox. That way, when I create a new page, I can just drop a menu and choose which section this new page will be in. I usually call one section NA for not applicable and use it for miscellaneous pages that don't fit into a section.

Let's take this site as an example. The page you're reading now would fall under the Documentation section. So I'll choose Documentation for the Section meta type that I get to see when I'm composing this page.

Here's a screenshot so you know what I'm talking about:

Composing Page Image:

Now, on my Site Index page, all I have to do is tell the Metadata Plugin that I want a list of all pages in the Documentation section. With The searchkw() Macro it's easy. I just make a section heading and add the macro afterwards:

<h3>Documentation</h3>
{metaDataMacros.searchkw("Section","Documentation")}

Here's what we get:

Documentation

[Macro error: Internal database error: attempted to read a free block. Try to Save a Copy and relaunch with the new database.]

Now I just do that for each one of the sections in my website and presto! an automatic site index that never needs to be updated (unless you add a new section).

Some of you more astute readers will be thinking a couple of things to yourself. One is, you want to sort the index alphabetically instead of the seemingly random order they're in in the list above. Another is, you don't like regular HTML lists. You want special formatting. No problem. We just have to add the sortBy parameter to the searchkw macro so the Metadata Plugin knows how you want your results sorted, and you can provide formatting information if you wish.

We know there's a built-in meta type called Subject which is set to the title of your page (why is it not called Title? I dunno, you'll have to ask the Userland team), so let's just tell the plugin that we want it sorted by the built-in meta type Subject. Since the Metadata Plugin treats built-in and user-defined meta types the same, there's nothing special we need to do; it's as you would have guessed. The only thing is, Manila doesn't allow macros typed into pages to have optional parameters, so we have to give all the parameters explicitly:

{metaDataMacros.searchkw("Section","Documentation","Subject","<ul>","</ul>","<li>","</li>",
50,"includeself","suppressSortby")}

Of course, you remember the syntax of searchkw by heart but I'll repeat it here just for those who don't:

metaDataMacros.searchkw(metaname,metavalue,sortBy="score",header="<ul>",
footer="</ul>",beforeItem="<li>",afterItem="</li>",
maxItems="50",includeSelf="includeSelf",
suppressSortby="suppressSortby")

So here is our automatic site index for the Documentation section, sorted by Subject:

Documentation

[Macro error: Internal database error: attempted to read a free block. Try to Save a Copy and relaunch with the new database.]

Now you just have to do it for the remaining site sections, and you're done!

So why doesn't this site have a site index? Er, uh... :)

Note: support for hierarchical site indices is now supported in the metadata plugin internals but we don't have a handy macro for it yet.


This page last updated Friday, February 8, 2002 at 2:12:41 PM. (10078)