Velocity Coder
Giving you the edge with Apache Velocity
Introduction
Code Commenting
Cookies
Create a cookie
Delete a cookie
Retrieve cookie value
Create and display a cookie with multiple values using XML
Create an Array / List
Date Handling
Add and remove days from date
Return todays date
Return calendar objects
Format a date
List of date variables
Comparing Dates
Convert date field to HTML date
File include (dotParse)
Foreach Loops - Range Operator
Get logged in user and role
Get Query String Parameters
Single value
Multiple values
Inputing data to structures
Macros
Pulling data from structures
Standard - By Identifier
Standard - Single
Standard - Multiple
Pull with all subcategories of a main category: eg: Teams:
Published data only
Pulling and Displaying Related Content
Randomise the results:
Odd / Even rows
Pulling results from an RSS feed
Querying structures
Single value
Multiple values
Exclude values
Ordering results by one filter / sort
Ordering results by two sorting filters
Searching one structure with values from another structure
Other query examples
Retrieve binary file names (from Structure)
Retrieve binary image files
String Conditionals
if True
#elseif / #else
if this and that
if this OR that
String Functions
Setting a variable string
String - Contains
String - Change Case
String - Equals
String - Escape
String - Hide if null
String - isSet()
String - Mathematics
String - Remove the last character of a string
String - Replace
String - Trim
Useful Methods
Velocity Count:
List Size() - Can be used to determine if a pullContent query brought any results:
Find Folder
Get Content from inode
String: Substring and Index of:
dotCMS Variables:
Phone Formatter:
Page Title & Crumbtrail:
Get Category:
Pull Link from a structure:
Framed image
Parse a container
Sort with velocity
if in edit mode
Truncate
STOP script - debugging issues
Summary link to dynamic detail page
Fake Crumb Title
Thumbnail Generator:
Get a list of files from repository
Working with JSON
Creating a JSON file
Displaying results from a JSON page
Get Category:
#set($inode = $request.getParameter(
'inode'
))
#getContentDetail($inode)
#
if
($ContentletCategories.size() >
0
)
#set($catInode = $ContentletCategories.get(
0
))
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus