Recent Submissions

Flexible 2/3 column Template

This is a process which allows a template to be 2 OR 3 columns (live) based on what is in the 3rd column. That is, if the 3rd column is empty, it will...

Change the Page Title and Crumbtrail Title based on URLMapContent

This snippet shows how to check for URLMapContent in your Template, and change the page title and crumbtrail title accordingly.  

If you...

Localized Date Formatting

The $date Viewtool provided by dotCMS allows locale-specific date formatting, but a valid Locale instance needs to be passed to its...

Template Audit

Lists live/working templates in alpha order and which live/working html pages are using them.

Very basic, can probably be configured to list ...

Retrieve All Structure Names on Your System and Store them on a Drop Down List Custom Field

This custom field retrieves all structures in your system and display their names and identifiers on a drop down.

You can then use the name of...

SEO: Code to Prevent Duplicate Title Tags from Different Structures

Sometimes two or more structures can have structure items with the same page title.  Search engines may flag the pages as duplicate content.  ...

Sorting by Number then Alpha on File Repository listing

The File Repository Listing provides a vtl override that you can use to display your sorted files. In order to get it to arrange by number first (descending)...

Randomize a Query and Sort

This code snippet shows how to take a content pull, randomize the list for a specific number of results and then sort the randomized list afterward....

Using Dynamic Content's Image as Background Without Path in CSS

Do you ever find yourself loading multiple pieces of dynamic content onto a page and need to use an image path from that content as a background image...

IP Address Restrictor

This is code so that you can change the page based on the incoming IP Address - for example, we use it to:

A) Make certain information only available...

Loop through numbered fields

If you have multiple fields or groups of fields that are similar (i.e. "Image 1," "Image 1 Caption," "Image 2," "Image 2 Caption"), you should write...

Site Search with Google Site Search XML

This code will allow you to connect to Google Site Search's XML and display it's search engine results in your page. This is done on the server side...

Checking in content and relating it to a File as Content using dotCMS Content API

This code sample shows how to check-in content using Files as Content and a File field. The code allows to:

1) Check in a FileAsset (Files as...

Flexible Navigation Macro

This macro is designed to wrap the stock navigation() macro such that it will default to the current location depth, with a default depth, both of which...

Displaying a Key/Value field's data

This code shows how to display the data in a Key / Value field on a content type.

In this example the content type name is Products and ...

Disable Structure Fields in Back-end UI

This javascript, when placed into a custom field, will disable fields listed in the array "fieldsToDisable." making them uneditable by back-end UI users...

Lucene Syntax to Respect Publish and Expire Dates

If you are trying to...

Get all Categories in a Category Select

Use this to pull all selected categories in a widget category select. After you use this code to grab them you can make it part your dotcontent.pull...

Pull in your SEO Friendly Meta Description & Keywords

The SEO fields in Page Properties > Advanced Properties collect meta description and meta keywords.  A simple regex string replace here to remove...

Friendly Slug Custom Field (WordPress Style)

SEO-friendly URLs are a must-have nowadays. They not only help web pages rank better in search engines, but also help site visitors and content managers...