Updating metadata in a custom element in Site Studio
By Kyle Hatlestad on Jun 14, 2011
I was recently asked if it was possible to edit metadata on a Site Studio data file from an element instead of having to go to the Metadata tab specifically. Users were finding it disorienting to move back and forth between the Elements and Metadata tabs when updating both content and metadata.
So I put together an example that places a metadata update form within a custom element. It uses a couple of AJAX calls to the server to get the current metadata values (DOC_INFO) and to update them (UPDATE_DOCINFO). The sample includes 3 fields; Title, Type, and Comments.
It can be easily changed to add additional fields. Or you could make the entire custom element to be one particular metadata field. Much of the code in the sample has comments, so I won't go into detail here.
One function I did find particularly useful was the ability to pull in the dID and dDocName of the data file into the custom element form. The functions ElementAPI.GetFormProperty('dID') and ElementAPI.GetFormProperty('dDocName') were used in order to run the services against the content to pull and push the metadata information.
The sample can be downloaded here (right-click and save). Simply submit the file with the Web Site Object Type of 'Custom Element Form'. Then create a new Custom Element that points to the form. I've tried it in both 10gR4 and 11g.
Hopefully some other folks will find this helpful.