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:
- In the Data perspective, add a new Page meta type.
- On the Settings tab, specify these parameters:
- Name: "Marker"
- Namespace: "Metatypes"
- 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
- Save the meta type.
Next, add the meta type to pages:
- In the Content perspective, right-click a page and click Add Metadata Field to add the meta type you have just created.
- In Step 1 of the wizard, select the meta type you have created: Marker.
- In Step 2, keep the suggested values.
- In Step 3, specify "Sample Value of Marker" in the Marker Value field.
- Click Save.
Then, create an XSLT function to render the metadata on pages.
- In the Functions perspective, add a new XSLT function with following parameters:
- Name: "MarkerRendering"
- Namespace: "Metatypes.Marker"
- Output type: "XHTML"
- In the function editor, on the Settings tab under Debug in the Page field, select the page you have added the meta type to.
- On the Function Calls tab, add the function (C1 has created to get data items of this meta type): Metatypes.Marker.GetMarkerXml.
- Click its Filter parameter and for the Parameter value type, select "Execute a function call".
- Select the function Metatypes.Marker.ActivePageReferenceFilter.
- 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" />
- On the Preview tab, you can see filtered data.
- Save the changes.
Finally, use the rendering function on a page with metadata:
- Edit the page where you have earlier added the meta type.
- Click Insert | Functions and select the function you have just created: Metatypes.Marker.MarkerRendering
- Click OK and save the changes on the page.
- Preview the page.
The page should read: "The Value of the input parameter 'Marker': Sample Value of Marker"