|
The Metadata Plugin Metadata Management for Manila |
Site last updated 2/24/2006; 12:33:21 PM |
|
query() MacroHere is the parameter list (note that only the first two parameters are required):
metaDataMacros.query (metaname,metavalue,sortBy:"score",
header:"<ul>",footer:"</ul>",
Setting metavalue to You don't have to set the adrFormatter parameter unless you've written your own formatter. If this macro isn't returning anything from within a news item and you think it should be returning something, set the msgNum parameter to the msgNum of the news item. Here's an example of all the pages on this site that contain the keyword 'metadata'. I've included the postTime and member built-in meta types in the beforeItem and afterItem parameters. Here's the macro verbatim, then the macro results beneath:
{metadatamacros.query("keywords","metadata","postTime", [Macro error: Internal database error: attempted to read a free block. Try to Save a Copy and relaunch with the new database.] Those of you with sharp eyes will wonder why we used {-postTime} instead of {postTime} when we want to display the built-in meta type postTime. It turns out that postTime gets evaluated before the Metadata Plugin even sees it, which results in the postTime of the page containing the macro being used over and over, instead of the postTime for the messages being used. By using the hyphen, we sneak it in unscathed. Dateformat parameter can be set to shortstring, abbrevstring, or longstring. Date Range Searching The operator parameter in the query macro allows you to do date range searching. If you have a metadata field that is indexed and of type 'date' you can construct querys that search date ranges including: range, rangeInclusive, equalTo, greaterThanOrEqualTo, greatherThan, lessThan, lessThanOrEqualTo, MIN & MAX. For example, supppose you have a metaData field called requestDate of type date and you wanted to find all messages that had a requestDate between 05/01/03 and 06/31/03. Construct a call to query using parameters as needed and then pass 1) metavalue as {"05/01/03", "06/310/03"} and 2) pass operator as operator:"rangeInclusive" at the end of the query parameter list. Other Notes
Because of the way Frontier tables sort, sorts are case-sensitive. If you want to make sorts case-insensitive, go to item^ = metavalRetrieved to read item^ = string.upper(metavalRetrieved) Note that there will be a speed penalty for doing this, since every search match must be converted to uppercase. For details on the constrainBy parameter, see The showIndex() macro documentation. David Bayly has put together a graphical front end for the query macro. You can view it by clicking Query Builder on the Manage Meta Types page. This is handy for tweaking parameters to the query macro to get them just right. Here's what the query builder interface looks like:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This page last updated Friday, October 17, 2003 at 2:16:19 PM. | (21795) |