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

 
 

Custom Field Formats

Author:   John VanDyk  
Posted: 3/7/2001; 2:36:19 PM
Topic: Custom Field Formats
Msg #: 635 (top msg in thread)
Prev/Next: 634/636
Reads: 7359

A custom field format uses a callback to generate HTML for the input field. Here's how it works.

When you pick a field format for one of your meta types, the Metadata Plugin builds a form for that field when you edit a page in your browser. You can pick among a variety of field formats, like dropbox or checkbox. But sometimes you want to customize the input form beyond what the plugin gives you. Maybe you want to use JavaScript field validation or play an annoying sound when the cursor enters the field. The custom field format allows you to do this.

When you pick custom for the field format of your meta type, the Plugin will look for a script to generate the HTML for the input field. Where will it look? Suppose you have a meta type named 'keywords'. The plugin would look in @myManilaWebsite.["plugins"].data.metaData.keywords.

When you choose custom as the field format, the plugin copies an example script to that location. Simply modify the example script or delete it entirely and replace it with your own.

Here are the comments and contents of the example script:

This script is executed when the Metadata Plugin is building the editing form for editing metadata. It looks for a script that has the same name as the meta type it's currently building a form for.

This script is copied from metaDataData.callbacks.defaultCustomFormat.

There is a copy of this script for each custom meta type. Eg., if the keywords meta type has it's format set to custom, this script would be found at @myManilaWebsite.["#plugins"].data.metaData.customFormats.keywords.

This script needs to return a table row (two columns) with a valid input field.

If you need msgNum or other info, check the gridtable (eg. pta^.gridtable.msgNum)

The following variables are in scope:

  • pta - the page table address
  • metaname - the name of this meta type
  • s - the value of the meta type, already retrieved from the gridtable and coerced to a string
  • len - the length, in characters, that the user wants this field to be
  • ht - the height, in rows, the user wants this field to be

A simple script is given for you below. You should comment it out and replace it with your own.

return("<tr><td align='right'><b>" + metaname + "</b></td><td><input type='text' name='" + metaDataSuite.metaEdit.dsp_prefix + metaname + "' value='" + s + "' size='" + len + "'></td></tr>")


This page last updated Sunday, June 30, 2002 at 2:27:42 PM. (7359)