Using meta attributes

Here you learn about the various ways to use meta attributes in Gentics CMS.

If you’re just looking for a compiled list of meta attributes head over to the List of meta attributes

1 Syntax

1.1 Node-Style

The Node-style syntax is available in pages, templates and tags. When the rendered attribute is a tag, it will be rendered with the appropriate icons.

Rendering tags in edit mode via the Node-Style syntax can cause problems, if the template contains “<” or “>” characters (for example <?php ... ?>). Consider using the #gtx_edit render directive.

Example: print the page name

  <node page.name>
 

1.2 Velocity-Style (VTL-Style)

Rendering tags with the plain Velocity-Style syntax will not generate tag icons. Use the #gtx_edit render directive to render tags in edit mode.

VTL stands for “Velocity Template Language” and stands for the syntax of “Velocity” (a template language) - see Velocity part type and Using Velocity in Tagtypes for details.

Example: print the page name

	$cms.page.name

If a Tagtype contains a part names “class” Velocity syntax cannot be used to resolve its value because it would just return the Tagtypes Java class. Use getProperty as a workaround.

Example: accessing a part named class

## won't work as expected will just return a Java class
$cms.tag.parts.class

## this will work as expected
$cms.tag.parts.getProperty("class")

1.3 Tagmap-Style

The Gentics CMS Tagmap requires no special syntax – you can access the properties directly.

Example: print the page name

	page.name

This syntax is only available in the Tagmap editor in the field “tagname”.

1.4 Resolving properties

You can chain properties together using a dot-syntax to traverse through linked objects

Example: display lastname of the folders creator

  <node page.folder.creator.lastname> // Node-Style
  $cms.page.folder.creator.lastname // VTL-Style
  page.folder.creator.lastname // Tagmap-Style

2 Baseobjects

These are the base objects that can be used in the CMS, along with examples on how they can be accessed and in which contexts they are made available.

Object Velocity example Node-Style Example Availability
page $cms.page.name <node page.name> page
template $cms.template.id <node template.id> page, template
file $cms.file.name <node file.name> file
folder $cms.folder.name <node folder.name> folder, file, page
node $cms.node.host <node node.host> file, folder, page, tag, template
object $cms.object.startpage <node object.startpage> file, folder, page
rendermode $cms.rendermode N/A file, folder, page, tag, template
imps $cms.imps.string N/A file, folder, page, tag, template
tag $cms.tag.parts.url <node url> tag

2.1 Page

Access the list of page meta attributes from the list of meta attributes page.

The actual pageobject is only available in pagecontext (pages, pageurl’s, page overviews, pagetags).

Example: render the publish date

	<node page.publishdate> // Node-Style
	$cms.page.publishdate // VTL-Style

A very common use case is to check whether a page exists using a Velocity if-statement.

Example: check if a page exists

## bad - the whole page will be rendered
#if("$cms.page.languageset.pages.en" != "")
<a href="$cms.page.languageset.pages.en.url">English</a>
#end

WARNING: When checking if pages exists in Velocity if-statements it's best to always check for page ids rather than checking for the page itself, as any direct invocation of a page object will render the page. This is rather costly if you just want to check if a page exists.

## good - best performance
#if($cms.page.languageset.pages.en.id)
<a href="$cms.page.languageset.pages.en.url">English</a>
#end

2.2 Template

Access the list of template meta attributes from the list of meta attributes page.

The basic object applies to the actual template and provides the access for some properties of the template.

Example: resolve the template id

	Node Style: <node template.id>
	VTL Style: $cms.template.id

2.3 Folder

Access the list of folder meta attributes from the list of meta attributes page.

The basic object offers information about the folder.

Example: resolve the folder name

Node Style: <node folder.name> 
VTL Style: $cms.folder.name

2.4 File

Access the list of file meta attributes from the list of meta attributes page.

This basic object is not available page context, but in context of object properties and overviews.

Example: output the filename

Node Style: <node file.name> 
VTL Style: $cms.file.name

2.5 Node

Access the list of node meta attributes from the list of meta attributes page.

This basic object applies access to information of the actual node.

Example: output the hostname

Node Style: <node node.host> 
VTL Style: $cms.node.host

2.6 Object

Applies access to the object properties of the actual object.

Example: access object property color of the page

$cms.page.object.color

If an object property is not found on the current object a fallback mechanism will be triggered.

  1. when using a page object Gentics CMS will try to resolve the object property from the template ($cms.template.object.color)
  2. if not successful resolving will continue with the folder object ($cms.folder.object.color)

2.7 Tag

Access the list of tag meta attributes from the list of meta attributes page.

This basic object applies access to information of a tag in a page.

Example: access a tags name

Node Style: <node [TAGNAME].name> 
Node Style: <node tag.name> 
VTL Style: $cms.page.tags.TAGNAME.name

2.8 Rendermode

Rendermode is only available when using velocity syntax. Access the list of rendermode meta attributes from the list of meta attributes page.

This basic object applies access to information of the actual node during rendering with velocity.

Example: Output publish status

VTL Style: $cms.rendermode.publish

2.9 Imps

Access the list of imps meta attributes from the list of meta attributes page.

This basic object allows access to information of velocity imps.

Example: accessing the velocity string imp

$cms.imps.string

Velocity GenericTools contains a collection of reusable and well documented tools and utility classes of general interest to Velocity users. These classes and tools have no dependency on the VelocityView or VelocityStruts sub-projects. The tools may be used as you would any other POJO (“plain old java object”).

3 Childobjects

Child objects are only available from the context of a base object.

3.1 Language

Access the list of language meta attributes from the list of meta attributes page.

This property allows you to access information related to the current page language as well as other language variants of the page.

Example: print language code of page
 
Node Style: <node page.language.code> 
VTL Style: $cms.page.language.code

3.2 Pagetag/Templatetag Parttype

This object is used to access information of page- or templatetags.

Example: access tagid from tag linked via a pagetag

$cms.page.tags.pagetag.tag.id

3.3 Text Parttypes

The following Text Parttypes are available for use. Some Parttypes will modify you textual contents as described:

Parttype Modification
Text Short none
Text Linebreaks (\n) will be replaced by <br /> tags
Text/HTML These Parttypes will remove all trailing whitespaces and replace all linebreaks by newline characters (\n). In the next step the following HTML tags will have a <br /> tag appended to them: <b>, <strong>, <i>, <font>, <div>, <span> and <br>.
Text/HTML Long
HTML none
HTML Long

We strongly suggest not to use Text/HTML and Text/HTML Long Parttypes in your implementation as their replacing behaviour will confuse implementers and editors. Those parttypes are only available for legacy support.

3.4 Markuplanguage

The markuplanguage attribute allows you to access the markuplanguage setting of a template.

Example: ouput the name of the markuplanguage

Node Style: <node page.template.ml.name>
VTL Style: $cms.page.template.ml.name

3.5 User

Access the list of user meta attributes from the list of meta attributes page.

Example: ouput the pages creators lastname

Node Style: <node page.creator.lastname>
VTL Style: $cms.page.creator.lastname

3.6 Overview Template

Overview templates are used in overview parttypes. They use a special syntax. Inside an overview you have access to the object that is currently listed as well as some meta properties.

Example: list of pages with numbering

<node ds_pageoverview>
<!-- 
	will generate output like
	<p>News Page (1/12)</p>
	<p>Another Page (2/12)</p>
	<p>Third Page (3/12)</p>
	...
-->
<p><node page.name> (<node ds.nr>/<node ds.count>)</p>
</node ds_pageoverview>