Built-In Content Objects

Last Updated: Jun 17, 2024
documentation for the dotCMS Content Management System

The simplest way to access content in Velocity is through the use of one of three built-in ContentMap objects:

ObjectUse
$dotPageContentAccessing Page content
$URLMapContentAccessing URL-Mapped content
$dotContentMapAccessing any content in a container

A ContentMap is the object type that results from a content pull. Accordingly, these pre-defined variables allow reference to the content object without the need to pass an identifier to a $dotcontent.find() call.

Because of their convenience and wide coverage, these objects should be considered the de facto standard way to access content in Velocity, replacing calls to $dotcontent in most use cases. However, there remain cases where the latter proves indispensable — for example, it can be used in association with the NavTool Viewtool to fetch menu items.

To access a field within the content object, call its variable as a property — e.g., $dotPageContent.title, $URLMapContent.host $dotContentMap.varName, and so on. All methods accessible by way of a standard content pull are available through these objects.

Methods

In addition to exposing the content object, ContentMaps also make available the following methods:

Property/MethodBehavior
identifierReturns the full-length identifier of the contentlet.
inodeReturns the full-length UUID of the contentlet's inode.
get("varName")Returns the field specified by varName; $dotContentMap.get('foo') is the same as using $dotContentMap.foo. As you will see below, get functions that do not take arguments can also be represented as properties by removing “get” and lowercasing the next letter.
getRaw("varName")Returns the unparsed data of the field specified by varName, including the raw text of any Velocity code.
getShortyUrl()Returns the identifier-based URI for the first file in a piece of content. Equivalent to the property .shortyUrl.
getShorty()Returns the short version of the content identifier. Equivalent to the property .shorty.
getShortyInode()Returns the short version of the content inode. Equivalent to .shortyInode.
getShortyUrlInode()Returns the inode-based URI for the first file in a piece of content. Equivalent to .shortyUrlInode.
getUrlMap()Returns the URLMap for a piece of content, if one exists. Equivalent to .urlMap.
getStructure()Returns structural metadata for the object. Equivalent to .structure.
isLive()Returns true or false.
isWorking()Returns true or false.
isHTMLPage()Returns true or false.
getContentObject()Returns the object with which this map is associated. Equivalent to .contentObject.
toString()Prints the entire object as a raw string; similar to getRaw(), but for the entire contentlet instead of a single field.
getFieldVariables("varName")Introduced in 22.09, this returns a map of key-value pairs representing the field's field variables, where varName is the system variable assigned to the field at its creation.

On this page

×

We Dig Feedback

Selected excerpt:

×