Recent Submissions

Log Configuration Portlet

The Logging Portlet allows a CMS Administrator in dotCMS to dynamically set logging levels of classes and packages at runtime that are known to the ...

Navigation Macro based on dotCMS' navTool viewtool

This macro extends the functionality provided by dotCMS' navTool viewtool.

It is based on folders and will allow you to set a starting point...

Getting all the content objects on a page

We have been asked repeatedly how to get a list of all the content objects that have been placed on a page by a content...

Pulling Related Host Specific Content excluding Global Content

This example allows you to pull related content on a specific host without including global content that is assigned to System Host.

When using...

Displaying Hints on Form Fields

If you want to display a hint for each of your Form fields you can do so by using the following Javascript snipet.

This example uses the Form's...

Comparing Dates in Velocity

This code sample will help you learn different ways to obtain today's date and format it. It also shows how you can compare two dates, or one content...

Displaying Metadata values from a File Content Type

When a new file is uploaded dotCMS extracts its metadata and indexes it for searches or to be displayed.

This sample shows how to take a list...

Creating, accessing and deleting Cookies using Velocity CookieTool

Velocity provides a viewtool to create, access and delete cookies. The tool is called: CookieTool and can be used on a widget by calling: org.apache...

Using AND and OR to pull content by Categories

When pulling content by categories sometimes you need to match categories using an AND, or an OR or sometimes a combination of both.

The example...

Pulling Content using RESTful ContentAPI

This example shows how to pull content from an external dotCMS site using the ContentAPI and displays the results paginated.

Using the Widget API

Since dotCMS 2.1 we provide an API to render a Widget based on its identifier.

This example shows how to use the api to pull a Widget from another...

Password Custom Field

The following code can be used to add a Password field to a content structure, including a Form.

Take the following steps to add a Password /...

Adding Categories to Content when Calling Checkin

The code below can be used to add a category by key to a contentlet when calling the checkin method.

Creating a List of Maps and adding to Session

This codeshare shows how to create a List of Maps of Strings, and to "set" and "get" the List on an attribute in the HTTP Session.

Parsing a JSON String using Jquery and Velocity

If you have a field on a content type that stores a JSON string, you can parse the string using a combination of Velocity and JQuery.

JQuery ...

Create a "Parse VTL" Widget Structure

This example allows you to execute the code in vtl files by simply browsing for them and saving a piece of widget content.

Tired of having to...

Script to Remotely Deploy OSGI jar

This is a bash script that will allow you to remotely deploy an OSGi plugin via the command line.  This is helpful when developing remotely

Image gallery that works with file assets and documents

The default version of image-gallery.vtl that comes with dotCMS only works with image files of type Document.  If a folder contains image files...

Handling XML Feeds with Children and Namespaces

The code below is a quick example on how to handle nested children in a simple XML feed and how to handle namespace fields that have a ":" in them.


Date Looping

This is how you can loop over a range of dates in velocity