Using Metadata field for JavaScript

lmwatson's Avatar

lmwatson

10 Mar, 2011 01:21 PM

I created a Dynamic Metadata text field named javascript and included the following in the Template:

The user would put in JS without the script tags. I tried this and the JS is not showing on the page in "view source".

I also tried just: <system-page-javascript/> where the user put in the entire script.

Am I missing a step?

  1. 1 Posted by Charlie Holder on 10 Mar, 2011 01:52 PM

    Charlie Holder's Avatar

    The system-page-* tags are predetermined within the system. The tags that you are referencing simply do not exist. To gain access to the content that you are looking for, you'll want to find the XML node called "dynamic-metadata" in the page XML that has a node with name you supplied when you created the dynamic field.

    An example structure you might see in the page XML is as follows:

    <dynamic-metadata>
        <name>my-field</name>
        <value>my value</value>
    </dynamic-metadata>
    

    Please note that if you multiple dynamic-metadata fields, you will have multiple dynamic-metadata nodes and not multiple name/value combinations inside a single wrapper.

    You will traverse the page XML and render the content the same way you do for formatting structured data for a data definition.

  2. 2 Posted by lmwatson on 10 Mar, 2011 02:05 PM

    lmwatson's Avatar

    That makes sense thanks

  3. Charlie Holder closed this discussion on 15 Apr, 2011 07:57 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac