Built-In Content Objects

Last Updated: Aug 24, 2022
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.
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.
getShorty()Returns the short version of the content identifier.
getShortyInode()Returns the short version of the content inode.
getShortyUrlInode()Returns the inode-based URI for the first file in a piece of content.
getUrlMap()Returns the URLMap for a piece of content, if one exists.
getStructure()Returns structural metadata for the object.
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.
toString()Prints the entire object as a raw string; similar to getRaw(), but for the entire contentlet instead of a single field.
getFieldVariables("varName")Planned for introduction in 22.09, this returns a map of key-value pairs representing the field's field variables. This is the first general-purpose method for retrieving field variables within Velocity.

On this page