Developer FAQ

How to render values from Page meta types?

Answer:

We will use an XSLT function to render the values of the Page meta type on a page.

First, create a Page meta type:

  1. In the Data perspective, add a new Page meta type.
  2. On the Settings tab, specify these parameters:
    • Name: "Marker"
    • Namespace: "Metatypes"
  3. 3. On the Fields tab, add a field with these parameters:
    • Name: "MarkerValue"
    • Label: "Marker Value"
    • Field type: String
    • String maximum length: 64 character maximum
  4. Save the meta type.

Next, add the meta type to pages:

  1. In the Content perspective, right-click a page and click Add Metadata Field to add the meta type you have just created.
  2. In Step 1 of the wizard, select the meta type you have created: Marker.
  3. In Step 2, keep the suggested values.
  4. In Step 3, specify "Sample Value of Marker" in the Marker Value field.
  5. Click Save.

Then, create an XSLT function to render the metadata on pages.

  1. In the Functions perspective, add a new XSLT function with following parameters:
    • Name: "MarkerRendering"
    • Namespace: "Metatypes.Marker"
    • Output type: "XHTML"
  2. In the function editor, on the Settings tab under Debug in the Page field, select the page you have added the meta type to.
  3. On the Function Calls tab, add the function (C1 has created to get data items of this meta type): Metatypes.Marker.GetMarkerXml.
  4. Click its Filter parameter and for the Parameter value type, select "Execute a function call".
  5. Select the function Metatypes.Marker.ActivePageReferenceFilter.
  6. On the Template tab, copy and paste the following code within the <body></body>:
    The Value of the input parameter 'Marker':
    <xsl:value-of select="/in:inputs/in:result[@name='GetMarkerXml']/Marker/@MarkerValue" /> 
    
  7. On the Preview tab, you can see filtered data.
  8. Save the changes.

Finally, use the rendering function on a page with metadata:

  1. Edit the page where you have earlier added the meta type.
  2. Click Insert | Functions and select the function you have just created: Metatypes.Marker.MarkerRendering
  3. Click OK and save the changes on the page.
  4. Preview the page.

The page should read: "The Value of the input parameter 'Marker': Sample Value of Marker"