Codeshare List of user-contributed code snippets for dotCMS Java CMS.

Recent Submissions

Conditionalized Structure Fields

Author: Michael Fienen |

This javascript code can be used in a custom field as an example of making fields visible conditionally based on the value of another field.

Getting the page context values

Author: Michael Fienen |

This will echo out all the Velocity variables set in the given page's context.

How to Display Content Type's Fields

Author: Dotcms |

On this example we will show how to use Velocity to display the values for each type of field on a content type. We created a new structure and added one...

Creating a List of Maps and adding to Session

Author: Dotcms |

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.

Bash Script to Copy and Index Using the Restful API

I have needed to do this from time to time, either for an upgrade, or to sync up a live system with a development system. The script below you would need...

1.9 Orphaned htmlpage SQL

Author: Chris Falzone |

From time-to-time we still have clients come to us with orphaned files. Here are the queries I use to find/fix them.

Using the Widget API

Author: Dotcms |

This example shows how to use the api to pull a Widget from another dotCMS installation and render it on your site.

Pulling a list of content into a custom field

Author: Jason Smith |

This code will pull a list of content into a custom field and create a select box for each result. Onchange it will set the value of the custom field.

Get Categories from Widget Selection- with And/Or selector

Author: Todd Reed |

This buildCatQuery will pull the categories from an array. Part of the widget also includes a field for And Or to join the categories together.

Loop through numbered fields

Author: Stephen Bell |

Write your velocity code once for multiple fields or groups of fields then put them into your page instead of repeating yourself for each one.