HTML in element set comment/description fields

Hi all,

I've been working on a little plugin to extend support for XML output to GeoBlacklight, which involved adding an element set of GeoRSS and Solr related fields. I haven't had any trouble with that, but I'm trying to provide some links in the text that accompanies the admin "Add Item" metadata element description (or the related "comment" field, which you can edit in the admin panel).

So, for instance, right above a metadata element input field for something like "GeoBlacklight Geometry Type", I'd like to have a link to an example document embedded within the description of what this field is. Whenever I have HTML tags in the "description" or "comment" field for my element_sets SQL table, it is never interpreted by the browser –– I just see the tags written, and injected into the text.

I've gathered that this has something to do with Omeka's HTML escaping... and that it is probably the same security feature that keeps html in form inputs from being printed out as HTML. Is there a way I can get these description or comment fields printed with HTML in the admin Add Item page though?

Thanks!
-s

That data all gets automatically escaped for HTML content.

You can use the ElementForm filter to replace or modify the description or comment components for your elements. That filter happens after the HTML escaping occurs, so your plugin could insert HTML at that point.

Hi John,

Thanks for the reply. I don't have a ton of experience with PHP, so excuse my ignorance on this matter.

I checked out the documentation for the ElementForm filter, but I'm not quite sure how to implement it. Where would I sue the filter? Would I do it in the plugin, before it issues "insert_element_set()"? Or would I do it on the admin page in which the description/comment is printed (I'm not sure exactly where that document is)?

best,
-stephen

It would be in the plugin, and listed as a separate filter that operates separately from your other code.

From the example, add the filter to the array of filters (if there is one -- if not copy that $_filters line). Change the name of the key in the filter from relabelItemTitle to a function name that's more descriptive. Then, create a new function with that name in your plugin.

In the function, in the $components array, you'll want to change the description and/or comment key:

$components['comment'] = "HTML Comment";
        return $components;

You'll need to add a new filter for each element that you need HTML for.

Patrick,

This is perfect! Thank you so much. Thanks to both of you for the help.

best,
-stephen