|
The Metadata Plugin Metadata Management for Manila |
Site last updated 2/24/2006; 12:33:21 PM |
|
The showIndex() macro
The showIndex() macro is used to display your index. You can see an example here. Syntax is similar to the other Metadata Macros. Note that only the first parameter is required; the others are all optional.
showIndex (metaname,constrainBy:"",sortBy:"score",beforeTerm:"<b>",afterTerm:"</b>", The beforeTerm and afterTerm are unique to this macro. The beforeTerm is inserted before each index entry and the afterTerm is inserted after each index entry. Note on the example page, above, that the index entries are bold. That's because we've specified <b> for the beforeTerm and </b> for the afterTerm. The other new parameter here is constrainBy. Let's explore that for a moment. Suppose I have my site divided into three sections: documentation, marketing fluff, and the weblog of my pet rat. I'm using a meta type called Section to automatically apply templates to the sections. I'm using a meta type called Keywords to associate keywords with every page. Now I want to generate the keyword index so that people can browse through the keywords and see which pages are listed under each. Easy. I just type {metaDataMacros.showIndex("keywords")} or, if I want everything sorted alphabetically, {metaDataMacros.showIndex("keywords",sortBy:"subject")} and I'm done, right? Not so fast, Bubba. That shows keywords for the entire site. I only want keywords for the Documentation section. How do we do that? We use the constrainBy parameter. I simply say {metaDataMacros.showIndex("keywords","Section=Documentation")} Now I get a keyword index generated for the Documentation section only. And my pet rat is not upset with me. You can also use != in your constrainBy expression, or use multiple expressions separated by commas, eg. {metaDataMacros.showIndex("keywords","Section=Documentation,keywords!=fox")} The constrainBy parameter does a logical AND. The main problem with this macro is that it's slow. You are basically doing the most expensive task there is: going through each entry in the index and doing time-consuming lookups of actual values. Of course, this will only happen once, and the results will be cached until a page on the site is changed. This macro was updated on 11/22/2000 to use the new getRelatedItems query engine. That means that you can include meta types as macros in your beforeItem and afterItem parameters. A side effect is that the suppressSortby parameter is now redundant (suppressing the sortBy results is the default behavior now), and values passed in this parameter will be ignored. Reverse sorting of the index can be achieved by setting the indexDirection parameter to reverseSort. An example: {metaDataMacros.showIndex("keywords",indexDirection:"reverseSort")} Sometimes you have entries in the index that have no corresponding pages. Maybe you added them so they'd appear in a dropbox, or you've got some special reason for them to be there. By default, the showIndex macro will list the term with an entry (None) under it. If you don't want the terms to show up at all, set the suppressEmptyTerms to something nonblank. {metaDataMacros.showIndex("keywords",suppressEmptyTerms:"suppressEmptyTerms")} If you want to show only the headings and no results under them, set the headingsOnly parameter. The following will simply give you a list of all the keywords: {metaDataMacros.showIndex("keywords",beforeTerm:"<b>",afterTerm:"</b><br>",headingsOnly:"true")} Note the use of the beforeTerm and afterTerm parameters to format the results when the headingsOnly parameter is used. There are responses to this message:
|
|||||||||||||||||||
| This page last updated Wednesday, May 21, 2003 at 9:42:57 AM. | (10770) |