@content

Fetches a single content instance by node id or path and makes it available to the template.

Parameters

parameter required description
id the ID of the node
path the path of the node
as specifies the name of the variable (by default - content)

Response

The response is a JSON object representing the node. The exact properties contained here will be dependent on the
properties of your content.

Examples

Example #1: Retrieve by Node ID

{@content id="922e6b9c9f4b7564bab"}
   <div>
      <span>{content.title}</span>
   </div>
{/content}

Example #2: Retrieve by Path

We can also do the same thing using a path-based approach.
This is useful for cases where we don't know the GUID of the node ahead of time.
We can look up the node using it's directory path.

{@content path="/folder1/folder2/content1"}
   <div>
      <span>{content.title}</span>
   </div>
{/content}

Example #3: Reusing a template

We can also split the template out from the directive.
This is useful if we have complex templates and want to reuse them.
For example, we might want to display two content items, as in this example:

{<template1}
   <div>
      <span>{content.title}</span>
   </div>
{/template1}
{@content id="922e6b9c9f4b7564bab"}
   {+template1/}
{/content}
{@content id="0123456789876543210"}
   {+template1/}
{/content}

As you can see above, we've retrieved two content items and have used the same template twice to provide consistent presentation for the content. In this case, {+template1/} tells Cloud CMS to process the content using the template identified by template1.