Using Taglibs in Web Content Templates

Liferay’s taglibs are accessible when developing templates in FreeMarker. There is no need to instantiate these taglibs within your FreeMarker template; they’re already provided for you automatically. You can access these taglibs by indicating the Tag Library Descriptor’s (TLD) file name with underscores.

When you’re using DXP’s template editor, you can find variables on the right side of the template editor under the Elements tab. To place one of the variables onto the template editor,

  1. Open the Site Menu (Site Menu) and select Content & DataWeb Content.

  2. Click the Templates tab and click New.

  3. Select the Elements tab on the right side of the page.

  4. In the Web Content Editor, position your cursor where you want the variable placed.

  5. Click the variable name.

Access variables under the Elements tab

If the variable name doesn’t give you sufficient information on its functionality, hover over the information icon (Information icon) for a more detailed description.

Hover over an information icon next to a variable for a more detailed description of the variable.

The interactive template editor is available for the FreeMarker, Velocity, and XSL languages. Depending on the language you select, the variable content changes so you’re always adding content in the language you’ve chosen. Autocomplete can be invoked by typing *${* which opens a menu of available variables. The editor inserts the variable into the template editor when it is chosen.

Note

The utilLocator, objectUtil, and staticUtil variables for FreeMarker are disabled by default. These variables are vulnerable to remote code execution and privilege escalation, and should only be enabled for trusted template developers.

After you save your template, DXP provides a WebDAV URL and static URL. These values access the XML source of your structure. You can find these URLs by returning to your template after saving it and expanding the Details section. For more information on WebDAV and the uses of the WebDAV URL, reference the WebDAV Access section.

Reserved Variables Under Journal

Here is a list of reserved variables you can find under Journal, what they return, and the methods called:

Reserved VariableReturnMethod
Article IDThe article’s reserved ID.journalArticle.getArticleId()
Author Email AddressThe author’s email address.journalArticle.user.getEmailAddress()
Author IDThe author’s ID.journalArticle.getUserId()
Author Job TitleThe author’s job title.journalArticle.user.getJobTitle()
Author NameThe author’s full name.journalArticle.user.getFullName()
CommentsThe author’s comments under More Information in account settings.journalArticle.user.getComments()
Create DateThe article’s date of creation.journalArticle.getCreateDate()
DescriptionThe article’s description.journalArticle.getDescription(languageId)
Display DateThe display date provided under Schedule.journalArticle.getDisplayDate()
External Reference CodeThe article’s external reference code.journalArticle.getExternalReferenceCode()
IDThe article’s ID.journalArticle.getId()
Modified DateThe last date the article was modified.journalArticle.getModifiedDate()
Resource Primary KeyThe resource primary key value.journalArticle.getResourcePrimKey()
Small Image URLThe URL for the feature image.journalArticle.getArticleImageURL(themeDisplay)
TagsThe article’s tags.AssetTagLocalServiceUtil.getTagNames(JournalArticle.class.getName(), journalArticle.getResourcePrimKey())
TitleThe article’s title.journalArticle.getTitle(languageId)
URL TitleThe article’s URL version of the title.journalArticle.getUrlTitle()
VersionThe article’s current version.journalArticle.getVersion()

Capabilities

Product

Contact Us

Connect

Powered by Liferay
© 2024 Liferay Inc. All Rights Reserved • Privacy Policy