freemarkercrafter-cms

Crafter CMS: retrieving data from a different page/content-type


Is it possible to retrieve data from a separate page? I only know how to use contentModel.VARIABLENAME in my ftl templates.

For example, I am currently in Page A but the data I want to display is from Page B.


Solution

  • You can use the siteItemService:

    <#assign pageB = siteItemService.getSiteItem("/site/website/path/to/pageB/index.xml") />
    

    You just need to replace path/to/pageB for the page path as shown in the Sidebar. The object returned is of the exact same type as contentModel, so you can do siteItemService.VARIABLENAME