Macros available in the dotCMS system

back to top
Build RSS This macro generates a RSS xml from a map list. Then name of the keys in the map have to be: 'title' (String - required), 'link' (Identifier - required), 'description' (String - required), 'guid' (Identifier -required), 'pubdate' (Date - optional) and 'author' (String - optional). This macro uses the permalink macro to generate the items link in the RSS.

Macro Syntax:

#buildRSS(channelTitle channelLink channelDescription list)
Arguments:

Usage:

The macro will display all the content obtained by the pullcontent macro in the RSS

Example: This show a simple way to call the macro with the required fields

#set($contentList = $!{contents.getEmptyList()})
#pullContent($query '0' 'modDate desc')
#foreach($content in $list)
#set($item = $!{contents.getEmptyMap()})
#set($_dummy = $item.put('guid', $!content.identifier))
#set($_dummy = $item.put('title', $content.title))
#set($_dummy = $item.put('description', $content.description))
#set($_dummy = $item.put('link', $!content.identifier))
#set($_dummy = $item.put('pubdate', $!content.contentLastModDate))
#set($_dummy = $!contentList.add($item))
#end

#buildRSS('Channel Title','http://hostname/test/test.dot','Channel description', $contentList)

Example2: This example shows how to include one o more of the optional parameters

#set($permalinkDetailPage='123')
#set($contentList = $!{contents.getEmptyList()})
#pullContent($query '0' 'modDate desc')
#foreach($content in $list)
#set($item = $!{contents.getEmptyMap()})
#set($_dummy = $item.put('guid', $!content.identifier))
#set($_dummy = $item.put('title', $content.titleField))
#set($_dummy = $item.put('description', $content.description))
#set($_dummy = $item.put('link', $!content.identifier))
#set($_dummy = $item.put('pubdate', $!content.contentLastModDate))
#set($_dummy = $!contentList.add($item))
#end

#buildRSS('Channel Title','http://hostname/test/test.dot','Channel description', $contentList)


back to top
Build RSS From Content This macro generates an RSS xml from a content lucene query.

Macro Syntax:

#buildRSSFromContent(channelTitle channelLink channelDescription query titleField descriptionField)
Arguments:

Usage:

The macro will display all the content obtained by the pullcontent macro in the RSS

Example: This show a simple way to call the macro with the required fields

#buildRSSFromContent('Channel Title','http://hostname/test/test.dot','Channel description','+type:content +deleted:false +structureInode:77290 +(+languageId:1* +live:true))','test1','test6')

Example2: This example shows how to include one o more of the optional parameters.

#set($permalinkDetailPage='123')
#buildRSSFromContent('Test Title','http://hostname/test/test.dot','Channel description','+type:content +deleted:false +structureInode:77290 +(+languageId:1* +live:true))','test1','test6')



back to top
comment: Add a Generic comment Component to a Page This macro will allow you to add a generic component to any contentlet in the system. If you set the commentsModeration you could create workflow task over this component.

Macro Syntax:

   comment($contentlet.inode)
Arguments: Optional Parameters:

Usage:
Use this macro if you want to add a form to comment a contentlet, the macro, will add a form to add new comments and list the comments order by publish date.

Example 1: #set($commentForceLogin = 'false')
#set($commentAutoPublish = 'true')
#set($commentUseCaptcha = 'true')
#set($commentUseAudioCaptcha = 'true')
#set($commentUseAudioCaptchaHeight = 200)
#set($commentStripHTML = 'false')
#set($commentTitle = 'This is the question to comment')
#comment($content.inode)

Example 2: This example generate a content comment and a workflow task from that comment

#set($commentForceLogin = 'false')
#set($commentAutoPublish = 'true')
#set($commentUseCaptcha = 'false')
#set($commentStripHTML = 'false')
#set($commentsModeration = 'Editor')
#set($commentForceLogin= 'true')
#comment($content.inode)


back to top
Return diferent messages depending the input date. The input date must be before the current date.

View Tool Syntax:

$dateviewapi.friendly(date)
Arguments:

Usage:

Use this to show the difference date and time between a string date (before the current date) and the current date.

Example 1:


Wed, 02 Apr 2008 16:23:14 +0000<br>
#set ($tempDate = $UtilMethods.parseDate("Wed, 02 Apr 2008 16:23:14 +0000", "EEE, dd MMM yyyy HH:mm:ss +SSSS"))
Result Message: $dateviewapi.friendly($tempDate)<br>
Assuming that current date is: Fri, 02 May 2008 17:20:00 - The output will be: Wed., April 2, 4:23 PM

Example 2:


Sat, 26 Apr 2008 16:23:14 +0000<br>
#set ($tempDate = $UtilMethods.parseDate("Sat, 26 Apr 2008 16:23:14 +0000", "EEE, dd MMM yyyy HH:mm:ss +SSSS"))
Result Message: $dateviewapi.friendly($tempDate)<br>
Assuming that current date is: Fri, 02 May 2008 17:20:00 - The output will be: Saturday at 4:23 PM

Example 3:


Thu, 01 May 2008 16:23:14 +0000<br>
#set ($tempDate = $UtilMethods.parseDate("Thu, 01 May 2008 16:23:14 +0000", "EEE, dd MMM yyyy HH:mm:ss +SSSS"))
Result Message: $dateviewapi.friendly($tempDate)<br>
Assuming that current date is: Fri, 02 May 2008 17:20:00 - The output will be: Yesterday at 4:23 PM

Example 4:


Fri, 02 May 2008 14:20:00 +0000<br>
#set ($tempDate = $UtilMethods.parseDate("Fri, 02 May 2008 14:20:00 +0000", "EEE, dd MMM yyyy HH:mm:ss +SSSS"))
Result Message: $dateviewapi.friendly($tempDate)<br>
Assuming that current date is: Fri, 02 Apr 2008 17:20:00 - The output will be: 3 hour(s) ago

Example 5:


Fri, 02 May 2008 17:10:00 +0000<br>
#set ($tempDate = $UtilMethods.parseDate("Fri, 02 May 2008 17:10:00 +0000", "EEE, dd MMM yyyy HH:mm:ss +SSSS"))
Result Message: $dateviewapi.friendly($tempDate)<br>
Assuming that current date is: Fri, 02 May 2008 17:20:00 - The output will be: 10 minute(s) ago

back to top
detailPageLink : Gets the details page link for a given contentlet. The link title can also be specified, otherwise the macro will attemtp to find a contentlet field with the name 'title' and use this as the default link title. If the 'Detail Page' structure field has not been set, the link will be composed of the current page url plus the parameter. Note that the name of the request parameter used for passing the selected inode to the details page, is determined by the properties key "INODE_PARAMETER_NAME". In case this key is missing, the parameter name defaults to "inode"

Macro Syntax:

detailPageLink($content)
Arguments: Optional Parameters:

Usage:
Use this macro to get the detail page for a piece of content

Example 1: #set($linkTitle = 'My Title') #detailPageLink($content)


back to top
Content Rating The getRating macro, it's used to display a five start scale, that's the user's evaluation on the article. Also the macro allows the user evaluate this contentlet.

Macro Syntax:

#getRating(content_identifier)
Arguments:

Usage:

This macro will automatically show a five start menu indicating the acceptances for the contentlet.

Example:

#getRating($content.identifier)



back to top
Content Ticker

This macro takes a list of content items, and displays them each based on the titleField and titleDescription. It rotates each piece of content and fades them out of the page to show the next one. Optional parameters can determine the fade length and colors as well as the time between each ticker display.

Macro Syntax:

#ticker()
Arguments: Optional Parameters:

Usage:
Use this macro if you want to add a content ticker to your site. You need to call the pullContent macro before calling the ticker macro, to provide the ticker with the list of content to display.

Example:

#pullContent('+type:content +deleted:false +structureInode:5 +(+languageId:1* +live:true)' '10' '')
#set($titleField = 'NewsHeadline')
#ticker($titleField)

Example with Optional Parameters:

#pullContent('+type:content +deleted:false +structureInode:5 +(+languageId:1* +live:true)' '10' '')
#set($titleField = 'NewsHeadline')
#set($descriptionField = 'NewsSummary')

#set ($fadeInLenth = 500)
#set ($fadeOutLenth = 500)
#set ($displayLength = 2000)
#set ($fgcolor = "#1A50B8")
#set ($bgcolor = "#ffffff")

#ticker($titleField)

back to top
Crumbtrail Builder This macro will build a crumbtrail using the path to the current page using unordered lists. This list can then be formated by css. The resulting code will look like.
<ul>
	<li><a href="/">Home</a></li>
	<li><a href="/folder_name/">Folder Name</a></li>
	<li>Page Name</li>  <-- No Link for current page
</ul>

Macro Syntax:

#crumbTrail()
Arguments: Optional Parameters:

back to top
Display File, Page or Contentlet Trackback History This macro display a list of all the trackback pings made to the permalink showing the title,url, trackback date,blog name, and asset Identifier

Macro Syntax:

#pullTrackbacks(identifier)
Arguments:

Usage:

Example:

#pullTrackbacks('12345')
#if($list.size() >0)
#foreach($track in $list)
Asset Identifier:$!{track.assetIdentifier}
Title:$!{track.title}
Excerpt:$!{track.excerpt}
URL:$!{track.url}
Blog Name:$!{track.blogName}
Trackback Date:$!{track.trackDate}
#end
#else
  • No Trackbacks found

  • #end



    back to top
    Displaying Resized Images This macro will automatically create and display a resized image in your image html tag, with the height and width you specify in the servlet parameters. The servlet allows you to create new images with the size you prefer, specifying the width, height or both. If you want to display an image, but you don't know the exact values of the width and height to display the image proportionally, this servlet allows you specify the maximum height and maximun width the image could have, and generate a proportional image that doesn't exceed those values.

    Macro Syntax:

       <img src="/resize_image?[[path] or [inode]]
       &[ [[height] and/or [width]] or [[maxh] and [maxw]] ]">
    
    Arguments:

    Usage:
    The use of this servlet is very easy. You only have to add in the src attribute of the html image tag, the following text < img src="/resize_image?<parameters> " >

    Example:

       <img src="/resize_image?path=/images/image.jpg&maxw=120&maxh=130">
       <img src="/resize_image?inode=91&maxw=120&maxh=130">
       <img src="/resize_image?path=/images/image.jpg&w=80&h=80">
       <img src="/resize_image?inode=91&w=80&h=80">
       <img src="/resize_image?path=/images/image.jpg&w=80">
       <img src="/resize_image?inode=91&w=80">
       <img src="/resize_image?path=/images/image.jpg&h=80">
       <img src="/resize_image?inode=91&h=80">
    
    
    
    back to top
    Displaying Thumbnail Images This macro will automatically create and display a thumbnail image in your image html tag, with the height and width you specify in the servlet parameters. The servlet allows you to create new images with the size you prefer, specifying the width, height or both.The thumbnail generates an image with a background color and places the resized image within the thumbnail. The background color can be changed with the parameters r,g,b.

    Macro Syntax:

       <img src="/thumbnail?inode=[inode]&[ [[height] and/or [width]] or [[r] and [g] and [b]] ]">
    
    Arguments:

    Usage:
    The use of this servlet is very easy. You only have to add in the src attribute of the html image tag, the following text < img src="/thumbnail?<parameters> " >

    Example:

       <img src="/thumbnail?inode=91&w=120&h=130">
       <img src="/thumbnail?inode=91&w=120">
       <img src="/thumbnail?inode=91&h=130">
       <img src="/thumbnail?inode=91&w=120&h=130&r=200&g=100&b=50">
    
    
    back to top
    Decrypt This macro allows to decrypt a string that was encrypted with #encrypt. The decrypted value is saved in the variable: $decryptedStr. If you want to echo out the decrypted value use: $crypt.decrypt('string to decrypt').

    Macro Syntax:

    #decrypt('string to decrypt')
    Arguments:

    Usage:

    Example:

    #encrypt('website@dotcms.org')
    #decrypt($encryptedStr)
    This is the decrypted value = $decryptedStr
    
    
    
    back to top
    Encrypt This macro allows to encrypt a string. The encryted emails can be used in email forms to avoid having email address in plain text. The encrypted value is saved in the variable: $encryptedStr. If you want to echo out the decrypted value use: $crypt.crypt('string to encrypt').

    Macro Syntax:

    #encrypt('string to encrypt')
    Arguments:

    Usage:

    Example:

    #encrypt('website@dotcms.org')
    #set ($to = $encryptedStr)
    
    
    
    
    back to top
    Events Listings

    Macro Syntax:

    #events('from' 'to')
    Arguments:

    Usage:

    Example:

    #events('1/1/2006' '2/1/2006')
    

    back to top
    Execute SQL Query This macro will allow you to execute a select statement on any predefined datasource.

    Macro Syntax:

       #getSQLResults('select * from table')
    
    Arguments:
  • dbMaxRow
    Optional: If you set dbMaxRow your results will be limited to your maxRows. When possible your should do this with a limit in your query./li>

    Usage:
    Use this macro if you want to pull data from a database and display the results within some piece of content. If the SQL throws an error it will store the error in a variable named SQLError. See the example below for instructions on how to use this. It is only optional that you check for the error but it is recommended that you do so that your sql won't fail silently.

    Example:

    #set ($dbConnection = 'jdbc/test1')
    #set ($dbStartRow = 1)
    #set ($dbMaxRow = 4)
    #getSQLResults('select * from test order by id')
    $SQLError
    #foreach($r in $results)
    $r.id
    
    #end

    Example 2 - Here you see the the error being checked for and a custom message being throw on error:

    #set ($dbConnection = 'jdbc/test1')
    #set ($dbStartRow = 1)
    #set ($dbMaxRow = 4)
    #getSQLResults('select * from test order by id')
    #if($SQLError)
    Custom SQL message - I Failed
    #else
    #foreach($r in $results)
    $r.id
    
    #end #end

  • back to top
    File Repository This macro will automatically create a file repository using the path sent to it as the "root" folder.

    Macro Syntax:

       #fileRepository('path')
    
    Arguments:

    Usage:
    The repository will show a list of files and folders that the view user has permissions to view. If the user is not logged in, they will only be able to view files and folders that have the CMS_ANONYMOUS read permission. If the user is logged in, they will be able to view any files and folders they have read permission on.

    Example:

       #fileRepository('/resources/documentation')
    
    This would build a file repository from the contents found in the CMS folder /resources/documentation. If there were any sub folders, the user would be able to click through and view these as well.
     #set($fileRepositorySourceCode = '/application/file_repository.vtl')
    #fileRepository('/documentation/repository') 
    
    And the /application/file_repository.vtl file could look like this
    #foreach($file in $fileRepository_filesList)
    #set($imgpath = "/resize_image?path=/dotAsset/${file.identifier}.${file.getExtension()}&w=178")
    
    <img src='$imgpath' alt=""/> #end
    Another example of code for /application/file_repository.vtl could be like this: <ul> #foreach($file in $fileRepository_filesList) <li> Filename: ${fileRepository_showFolder$file.fileName}
    Extension: ${file.getExtension()}
    Friendly Name:$!{file.friendlyName}
    File Size:$!{file.size}
    Publish Date: $!{file.publishDate} </li> #end </ul>

    back to top
    Loads a Piece of Content From its Identifier This macro will take an identifier of a piece of content and sets it to a variable $content

    Macro Syntax:

       
    		#getContent(contentIdentifier)
    	

    Example:

       
    		#set($id = $request.getParameter("id"))
    #if($id)
    #getContent($id)
    #end
    My title is $content.title

    back to top
    Let you retrieve result from a google mini appliance.

    View Tool Syntax:

    $googleapi.searchGoogleMini(client, collection, subcollection, query, metaquery, start, num, autoFilter)
    
    Arguments:

    Usage:

    Use this to pull search results from a google mini appliance, to make this web api work you have to setup the variable GOOGLE_MINI_SEARCH_URL on the dotmarketing.config.properties file pointing to the google mini appliance url like GOOGLE_MINI_SEARCH_URL=http://googlemini.dotcms.org

    The api returns an specific GoogleMiniSearch object that contains all the variables necessary to display all the retrieved results.

    GoogleMiniSearch Object - Attributes

    	searchTime - The time taken by the appliance to retrieve the results
    query - The request query
    fromIndex - The start index of results
    toIndex - The end index of retrieved results
    estimatedTotal - The estimated total of result based on the given query
    searchResults - The list of results, this is a list of GoogleMiniSearchResult objects
    hasNextPage() - Method that returns true if results has a next page to display
    hasPreviousPage() - Method that returns true if results has a previous page to display
    GoogleMiniSearchResult - Attributes
    	identationLevel - Level of indentation used for inner results
    mimeType - Mime type of the result
    resultURL - The url to the result
    title - The title
    generalRatingRelevance - Relevance of the document in google mini
    additionalSearchDetails - More details about the retrived document
    snippet - Result snippet
    metaTagsFields - A map of metatags associated to the result

    Example:

    
    #set($searchObj = $googleapi.searchGoogleMini("default_frontend", "Main_Site", "", "Knight", "", 0, 100, false))
    <b>Search Summary</b><br/>
    <b>Total Search time:</b> $searchObj.searchTime<br/>
    <b>Query:</b> $searchObj.query<br/>
    <b>From Index:</b> $searchObj.fromIndex<br/>
    <b>To Index:</b> $searchObj.toIndex<br/>
    <b>Estimated Total:</b> $searchObj.estimatedTotal<br/>
    <b>Has Next Results Page:</b> $searchObj.hasNextPage()<br/>
    <b>Has Previous Results Page:</b> $searchObj.hasPreviousPage()<br/>
    <b>Estimated Total of Results:</b> $searchObj.estimatedTotal<br/>
    <br/>
    
    #foreach($result in $searchObj.searchResults)
    	<b>Result Index:</b> $result.resultIndex<br/>
    	<b>Identation Level:</b> $result.identationLevel<br/>
    	<b>Title:</b> $result.title<br/>
    	<b>Snippet:</b> $result.snippet<br/>
    	<b>Result URL:</b> <a href="$result.resultURL">$result.resultURL</a><br/>
    	<b>General Rating Relevance:</b> $result.generalRatingRelevance<br/>
    	<b>Mime Type:</b> $result.mimeType<br/>
    	<b>Additional Search Details:</b> $result.additionalSearchDetails<br/>
    	<b>Meta Tags Fields:</b> $result.metaTagsFields<br/>
    	<hr/>
    #end
    

    back to top
    List of Files from Underlying File System This macro will return a list of files that are available in a folder on the underlying file system.

    Macro Syntax:

       #getFilesFromFS('path')
    
    Arguments:

    Usage:
    The repository will show a list of files in a folder on the underlying file system. WARNING: THIS MACRO BYPASSES THE CMS PERMISSIONS COMPLETELY.

    Example:

    #getFilesFromFS('/css')
    #foreach($file in $files)
       title: $!file.name 
    size : $!file.size
    prettySize : $!file.prettySize
    date : $!file.date
    prettyDate : $!file.prettyDate
    link: $!file.link
    #end
    This would build a list of file information found in the file system folder $WEB-ROOT/css.

    back to top
    Mailing List Generated on a Web Form that Displays the Public Mailing Lists This macro generates a checkbox list for all public mailing lists, in order to manage the user's email subscriptions to these mailing lists. This macro can be used either the user is logged in or using encrypted user id when the user is not logged in.

    Macro Syntax:

    #mailingList()

    Usage:

    The macro will display all public mailing lists name

    Example: Let's assume we have a page with this macro, let's call it mailinglists_subscription.dot, if the user is logged in, this page can be accessed directly and its content will have the following macro call

          #mailingLists()

    Example2: The user is not logged in, but we can access the prior page passing through the respective encrypted userId using the respective request parameter

          mailinglists_subscription.dot?ui=UUZVXTMAEvP6ABUja7Rkhg==



    back to top
    MP3 Player This macro will embed a streaming, flash based mp3 player using mp3s files you have uploaded into dotCMS.  dotCMS will parse the xml file info and automatically display the song information in the player.

    Macro Syntax:

    #mp3Player('path')
    Arguments:

    Usage:

    This macro will automatically display the following mp3 player

    Example:

    #mp3Player('/path/to/mp3s/file.mp3')
    #mp3Player('/path/to/mp3s/playlist.xml')
    The file /path/to/playlist.xml needs to generate the following format:
    
    
    <?xml version="1.0" encoding="UTF-8"?>
    <playlist version="1" xmlns="http://xspf.org/ns/0/">
    <trackList>
    <track>
    <location>http://$!{host.getHostname}/mp3s/file1.mp3</location>
    <creator>File Creator 1</creator>
    <title>File Title #1</title>
    <genre>Other</genre>
    <image>http://$!{host.getHostname}/mp3s/file1.jpg</image>
    </track>
    
    <track>
    <location>http://$!{host.getHostname}/mp3s/file2.mp3</location>
    <creator>File Creator 2</creator>
    <title>File Title #2</title>
    <genre>Other</genre>
    <image>http://$!{host.getHostname}/mp3s/file2.jpg</image>
    </track>
    
    <track>
    <location>http://$!{host.getHostname}/mp3s/file3.mp3</location>
    <creator>File Creator 3</creator>
    <title>File Title #3</title>
    <genre>Other</genre>
    <image>http://$!{host.getHostname}/mp3s/file3.jpg</image>
    </track>
    
    </trackList>
    </playlist>
    
    
    
    
    back to top
    MP3 Player Button This macro will embed a streaming, flash based mp3 player button using mp3s files you have uploaded into dotCMS.

    Macro Syntax:

    #mp3PlayerButton('song_url')
    Arguments:

    Usage:

    This macro will automatically display the following mp3 player

    Example:

    #mp3PlayerButton('/path/to/mp3s/example.mp3')
    #mp3PlayerButton('/path/to/playlist.xml')
    The file /path/to/playlist.xml needs to generate the following format:
    
    
    <?xml version="1.0" encoding="UTF-8"?>
    <playlist version="1" xmlns="http://xspf.org/ns/0/">
    <trackList>
    <track>
    <location>http://$!{host.getHostname}/mp3s/file1.mp3</location>
    <creator>File Creator 1</creator>
    <title>File Title #1</title>
    <genre>Other</genre>
    <image>http://$!{host.getHostname}/mp3s/file1.jpg</image>
    </track>
    
    <track>
    <location>http://$!{host.getHostname}/mp3s/file2.mp3</location>
    <creator>File Creator 2</creator>
    <title>File Title #2</title>
    <genre>Other</genre>
    <image>http://$!{host.getHostname}/mp3s/file2.jpg</image>
    </track>
    
    <track>
    <location>http://$!{host.getHostname}/mp3s/file3.mp3</location>
    <creator>File Creator 3</creator>
    <title>File Title #3</title>
    <genre>Other</genre>
    <image>http://$!{host.getHostname}/mp3s/file3.jpg</image>
    </track>
    
    </trackList>
    </playlist>
    
    
    
    
    back to top
    MP3 Player Extended This macro will embed a streaming, flash based mp3 player button using mp3s files you have uploaded into dotCMS.

    Macro Syntax:

    #mp3PlayerExtended('song_url')
    Arguments:

    Usage:

    This macro will automatically display the following mp3 extended player

    Example:

    #mp3PlayerExtended('/path/to/mp3s/example.mp3')
    #mp3PlayerButton('/path/to/playlist.xml')
    The file /path/to/playlist.xml needs to generate the following format:
    
    
    <?xml version="1.0" encoding="UTF-8"?>
    <playlist version="1" xmlns="http://xspf.org/ns/0/">
    <trackList>
    <track>
    <location>http://$!{host.getHostname}/mp3s/file1.mp3</location>
    <creator>File Creator 1</creator>
    <title>File Title #1</title>
    <genre>Other</genre>
    <image>http://$!{host.getHostname}/mp3s/file1.jpg</image>
    </track>
    
    <track>
    <location>http://$!{host.getHostname}/mp3s/file2.mp3</location>
    <creator>File Creator 2</creator>
    <title>File Title #2</title>
    <genre>Other</genre>
    <image>http://$!{host.getHostname}/mp3s/file2.jpg</image>
    </track>
    
    <track>
    <location>http://$!{host.getHostname}/mp3s/file3.mp3</location>
    <creator>File Creator 3</creator>
    <title>File Title #3</title>
    <genre>Other</genre>
    <image>http://$!{host.getHostname}/mp3s/file3.jpg</image>
    </track>
    
    </trackList>
    </playlist>
    
    
    
    

    back to top
    Navigation/Menu Builder This macro will build a navigational menu using unordered lists sutiable for standard top or left-hand navigation. These lists can then be formated by css. The resulting code will look like (where the 2nd <li> is the active link).
    <ul>
    	<li><a href="/path/to/pageOrFolder">Menu item 1</a></li>
    	<li class="active"><a href="/path/to/pageOrFolder">Menu item 2</a></li>
    	<li><a href="/path/to/pageOrFolder">Menu item 3</a></li>
    </ul>

    Macro Syntax:

    #navigation('startLevel' 'levelsToShow')
    Arguments: Optional:
  • menuSpans
    If the $menuSpans variable is set to true before the macro is called, then <span> tags will be added around each menu link, like:
    <li><span><a href="/path/to/pageOrFolder">Menu item 1</a></span></li>
  • openAllLevels
    If this variable is set all menu items will be displayed on the navigation with no regard to where the user is on the site. This is very useful for top navigation drop downs that need to show all links.
  • Syntax:


    #navigation('startLevel' 'levelsToShow')

    Example 1:

    <div id="topNav">
       #navigation(1,1)
    </div>
    
    This would build a top level menu one level deep.

    Example 2:

    <div id="leftNav">
       #navigation(2,2)
    </div>
    
    This would build a navigation bar 2 levels deep, which would open as the user clicked into a subsection.

    Example 2:

    <div id="leftNav">
    #set($menuSpans = true)
    #navigation(2,2)
    </div>
    
    This would build a navigation bar 2 levels deep, which would open as the user clicked into a subsection. It will also add span tags around all links.

    Example 2:

    <div id="leftNav">
    #set($openAllLevels=true)
    #navigation(2,2)
    </div>
    
    This would build a navigation bar 2 levels deep, which would open as the user clicked into a subsection.


    back to top
    Paging Contents Any list of contents in the content database can be pulled and displayed in a paginated fashion on the front end of your website by using the #pageContent() macro

    Macro Syntax:

    #pageContent('query' 'sort by' '# per page' '# current page')
    Arguments:

    Usage:

    This macro returns a list of content(s) on a variable named $list of contentlets $content. The contentlet's properties can be displayed by referencing their variable names. So $content.firstName would display the variable named firstName for the listed contents. The variable name can be found in the structure detail for the content type being used.
    If you need to add a link to a content detail page you will need to use the content's inode by adding this variable: $content.inode.
    Also, there are a group of variables set by this macro that help you know things like $totalResults that contains the total number of contents, $totalPages for the total number of pages, $firstPageRecord for the first record number of the current page, $lastPageRecord for the last record number of the current page, $hasNextPage true if has a next page, $hasPreviousPage true if has a previos page

    Example:

    #pageContent('+type:content +live:true +structureInode:5' 'date1' '5' '1')
    #foreach($content in $list)
    title: $!content.contentTitle
    summary: $!content.NewsSummary
    #end

    back to top
    Permanent Link to a File, Page, or Contentlet This macro create a permanent link to a File, Page or Contentlet from the identifier or inode of them and add the trackback RDF reference to the page.
    In the case where the identifier is from a contentlet, you could include which page you want to display the contentlet information, adding the page identifier in the optional parameter "permalinkDetailPage", if this parameter is not pass, the macro will look if the contentlet structure have a detail page set, using this page if this page is not set then use the same page where the permalink is include adding in the url the ?id param with the identifier.

    Macro Syntax:

    #permalink(identifier)
    Arguments:

    Usage:

    Example:

    #permalink('12345')


    Example2:

    #set($permalinkDetailPage='78945') #permalink('12345')


    Example3:

    #set($permalinkTitle ="The Title") #permalink('12345')



    back to top
    Permanent Link Trackback: Add RDF Trackback to a File, Page or Contentlet This macro create the RDF tracback reference in the page for a permanent link to a file, page or contentlet in the case of the contentlet it check if receive a parameter called "permalinkDetailPage" that is the inode or identifier of the content page detail. If not, check if the struture have a page default or return to the same page adding the parameter

    Macro Syntax:

    #trackback(identifier)
    Arguments:

    Usage:

    Example:

    #trackback('12345')



    back to top
    Photo Carousel This macro generates a carousel of photos, displaying sequentially one after another.

    Macro Syntax:

    #photoCarrousel (photoList photoDimensions)
    Arguments: Optional Parameters:

    Usage:

    The macro will display a carrousel of photos

    Example 1: This show a simple way to call the macro setting the image folder

    
    #set($imageFolder = '/global/images/screencaps/')
    
    #set($photoDimensions = $contents.getEmptyMap())
    #set($dummy = $!photoDimensions.put("width", "125"))
    #set($dummy = $!photoDimensions.put("height", "125"))
    #set($photoCarrouselAutoSlide = true)
    
    #set($photoList = $contents.getEmptyList())
    #photoCarrousel($photoList $photoDimensions)
    
    

    Example 2: This show a simple way to call the macro with the photo list fields

    #set($photoList = $contents.getEmptyList())
    
    #set($photo = $contents.getEmptyMap())
    #set($dummy = $!photo.put("url", "/html/1.jpg"))
    #set($dummy = $!photo.put("link", "http://www.yahoo.com"))
    #set($dummy = $!photoList.add($photo))
    
    #set($photo = $contents.getEmptyMap())
    #set($dummy = $!photo.put("url", "/html/2.jpg"))
    #set($dummy = $!photo.put("link", "http://www.google.com"))
    #set($dummy = $!photoList.add($photo))
    
    #set($photo = $contents.getEmptyMap())
    #set($dummy = $!photo.put("url", "/html/3.jpg"))
    #set($dummy = $!photo.put("link", "http://www.dotcms.org"))
    #set($dummy = $!photoList.add($photo))
    
    #set($photo = $contents.getEmptyMap())
    #set($dummy = $!photo.put("url", "/html/4.jpg"))
    #set($dummy = $!photo.put("link", "http://www.hotmail.com"))
    #set($dummy = $!photoList.add($photo))
    
    #set($photoDimensions = $contents.getEmptyMap())
    #set($dummy = $!photoDimensions.put("width", "125"))
    #set($dummy = $!photoDimensions.put("height", "125"))
    
    #set($photoCarrouselAutoSlide = true)
    
    #photoCarrousel($photoList $photoDimensions)
    

    Example 3: This show a simple way to call the macro with the photo list fields and showing captions

    #set($photoList = $contents.getEmptyList())
    
    #set($photo = $contents.getEmptyMap())
    #set($dummy = $!photo.put("url", "/html/1.jpg"))
    #set($dummy = $!photo.put("link", "http://www.yahoo.com"))
    #set($dummy = $!photo.put("caption", "Yahoo"))
    #set($dummy = $!photoList.add($photo))
    
    #set($photo = $contents.getEmptyMap())
    #set($dummy = $!photo.put("url", "/html/2.jpg"))
    #set($dummy = $!photo.put("link", "http://www.google.com"))
    #set($dummy = $!photo.put("caption", "Google"))
    #set($dummy = $!photoList.add($photo))
    
    #set($photo = $contents.getEmptyMap())
    #set($dummy = $!photo.put("url", "/html/3.jpg"))
    #set($dummy = $!photo.put("link", "http://www.dotcms.org"))
    #set($dummy = $!photo.put("caption", "dotCMS"))
    #set($dummy = $!photoList.add($photo))
    
    #set($photo = $contents.getEmptyMap())
    #set($dummy = $!photo.put("url", "/html/4.jpg"))
    #set($dummy = $!photo.put("link", "http://www.hotmail.com"))
    #set($dummy = $!photo.put("caption", "HotMail"))
    #set($dummy = $!photoList.add($photo))
    
    #set($photoDimensions = $contents.getEmptyMap())
    #set($dummy = $!photoDimensions.put("width", "125"))
    #set($dummy = $!photoDimensions.put("height", "125"))
    
    #set($photoCarrouselAutoSlide = true)
    
    #photoCarrousel($photoList $photoDimensions)
    


    back to top
    Photo Gallery
    The Photo Gallery "macro" pulls and displays all the photos (jpgs and gifs files) of a given folder, it also pulls and displays sub folders if they contain photos.

    Macro Syntax:

    #photoGallery('/thefolder')
    Arguments: Optional Parameters:

    Usage:

    Let say you have a folder structure like the following:

    /photo_galleries -> folder where resides photos and sub galleries
    /photo_galleries/photo1.jpg -> image of this top level gallery
    /photo_galleries/photo2.jpg -> image of this top level gallery
    /photo_galleries/gallery_1 -> folder where the first gallery resides
    /photo_galleries/gallery_1/index.jpg -> main image of this gallery
    /photo_galleries/gallery_1/XXX.jpg -> any other image of this gallery
    ...
    /photo_galleries/gallery_2 -> folder where the second gallery resides
    /photo_galleries/gallery_2/index.jpg -> main image of this gallery
    /photo_galleries/gallery_2/XXX.jpg -> any other image of this gallery
    ...

    So calling,
    #photoGallery('/photo_galleries')
    Will display photo1 and photo2 as photos located in the /photo_galleries folder and then will list gallery1 and gallery2 as sub photo galleries of the /photo_galleries folder, the index.jpg (or index.gif) images are used as the main images when sub photo galleries thumbnails are shown, if the subfolder doesn't contain an index image then the first image found in the folder will be used as the index image.

    To use the optional parameters you have to set them before the macro is called. E.G.
    #set($showPhotoTitle = false)
    #photoGallery('/photo_galleries')

    back to top
    Print Average Content Rating Prints out the average rating calculated by the dotCMS from the rating votes. It prints out the average rating formatted with two decimals. I.E. X.XX

    Macro Syntax:

    #printAverageRating(content_identifier)
    Arguments:

    Usage:

    Example:

    	#printAverageRating($content.identifier)
    



    back to top
    Print the Number of Votes of a Rated Content Prints out the number of votes of a content

    Macro Syntax:

    #printNumberOfVotes(content_identifier)
    Arguments:

    Usage:

    Example:

    	#printNumberOfVotes($content.identifier)
    



    back to top
    Pull RSS This macro will retrieve a RSS Feed and will return it in a list

    Macro Syntax:

    #pullRSS('url')
    Arguments:

    Usage:

    This macro returns a list with the RSS Feed. the macro will return the data in a variable called $list of contentlets $content.The contentlet's properties can be displayed by referencing their variable names. So $content.title would display the RSS entry title. there are four variable:
    title
    link
    description
    pubDate

    Example:

    #set($rssFilter = ['dotcms','dotmarketing'])
    #set($rssTotal = 10)
    #pullRSS('http://somesite/topnews.rss')
    #foreach($content in $list)
    title: $!content.title
    description: $!content.description
    #end

    back to top
    Pulling Content Any content or list of content in the content database can be pulled and displayed on the front end of your website by using the #pullContent() macro.

    Macro Syntax:

    #pullContent('query' '# results' 'sort by')
    Arguments:

    Usage:

    This macro returns a list or a single piece of content. If you specified more than one result you will have a variable named $list of contentlets $content. If you specified one piece of content, you can ignore the list and just use the $content variable. The contentlet's properties can be displayed by referencing their variable names. So $content.firstName would display the variable named firstName for the listed contents. The variable name can be found in the structure detail for the content type being used.
    If you need to add a link to a content detail page you will need to use the content's inode by adding this variable: $content.inode

    Example 1: This pulls a list of 5 content objects with structure inode 5 ordered by date1, and it displays the title and summary of each one.

    #pullContent('+type:content +live:true +structureInode:5' '5' 'date1')
    #foreach($content in $list)
    title: $!content.contentTitle
    summary: $!content.NewsSummary
    #end

    Example 2: This pulls a list of 1 random content objects with structure inode 5, and it displays the title and summary of each one.

    #pullContent('+type:content +live:true +structureInode:5' '1' 'random')
    #foreach($content in $list)
    title: $!content.contentTitle
    summary: $!content.NewsSummary
    #end

    back to top
    Pulling and Displaying Related Content (Relationships) Any related content (driven by structure relationships) can be pulled and displayed on the front end of your website by using the #pullRelatedContent() macro.

    Macro Syntax:

    #pullRelatedContent('relationship name' 'content inode' 'limit' 'sort by')
    Arguments:

    Usage:

    This macro returns a list of related content. After the macro is called you will have a variable named $list of content objects. The content's properties can be displayed by referencing their variable names. So $content.firstName would display the variable named firstName for the listed contents. The variable name can be found in the structure detail for the content type being used.
    If you need to add a link to a content detail page you will need to use the content's inode by adding this variable: $content.inode

    Example 1: This pulls a list of up to 100 content related to content with inode 4686 that is related through relationship: Annual_Report_Article-Audio and it orders it by Headline, Text and Modified Date

    #pullRelatedContent('Annual_Report_Article-Audio' '4686' '100' 'fullHeadline asc, bodyText desc, modDate')
    
    #foreach($content in $list)
    headline: $!content.fullHeadline
    body: $!content.bodyText
    #end

    Example 2: This pulls a list of up to 100 content related to content with inode 4686 that is related through relationship: Annual_Report_Article-Audio and it orders it by Headline, Text and Modified Date. This only pulls content that match the condition where the Headline starts with the word "test".

    #set ($condition = 'fullHeadline:test*')
    #pullRelatedContent('Annual_Report_Article-Audio' '4686' '100' 'fullHeadline asc, bodyText desc, modDate')
    
    #foreach($content in $list)
    headline: $!content.fullHeadline
    body: $!content.bodyText
    #end

    back to top
    Random Image: Return a random image from a specified folder You must provide to this macro a path in order in order to return a random image

    Macro Syntax:

    #randomImage (path)
    Arguments:

    Usage:

    The macro will return the image selected in the variable $image

    Example:

    #set ($path = '/global/images/')
    #randomImage($path) 
    <img src="/resize_image?inode=$!{image.inode}&w=911&h=322" alt="Top Banner" width="911" height="322" />
    



    back to top
    Retrieve Selected Inode Gets the inode selected by the user. Typically this will be used in 'detail' style pages (e.g. /news/details.dot), and therefore the inode will actually correspond to a selected contentlet. Note that the name of the request parameter used for extracting the selected inode, is determined by the properties key "INODE_PARAMETER_NAME". In case this key is missing, the parameter name defaults to "inode"

    Macro Syntax:

    #selectedInode()

    Usage:

    The macro will get the passed in inode for you

    Example:

    #selectedInode()


    back to top
    Send To Friend This macro generates a form to send an article to a friend by email.

    Macro Syntax:

    #sendtofriend (articleText)
    Arguments: Optional Parameters:

    Usage:

    The macro will display a send to friend form

    Example: This shows a simple way to call the macro with the required fields

    #set($sendToFriendStyle = "display:inline;")
    #sendtofriend('This is a Send To Friend test!!!')


    back to top
    Site Map: Add a Site Map to a Page.

    Macro Syntax:

       #sitemap()
    

    Usage:
    Use this macro if you want to add a site map for your whole site.

    Example:

    #sitemap() This would build a site map for everything from the root fo the site. It will stop at 100 levels deep.

    back to top
    Site Map Folder: Add a Site Map to a Page from a Folder to a Specific Depth.

    Macro Syntax:

    #siteMapFolder(2,2,'/folder1/myFolder')
    
    Arguments:

    Usage:
    Use this macro if you want to add a site map to your page from a specific path. You can specify how many level from the path to start and end.

    Example:

    #siteMapFolder(2,2,'/folder1/myFolder')
    
    This would build a site map for everything 2 levels beneath /folder1/myFolder and go 2 levels deep.



    Example2:

    #set($reverseOrder = true)
    #siteMapFolder(2,2,'/folder1/myFolder')
    
    This would build a site map for everything 2 levels beneath /folder1/myFolder and go 2 levels deep in inverse order.

    Example3:

    #set($showHome = true)
    #siteMapFolder(2,2,'/folder1/myFolder')
    
    This would build a site map for everything 2 levels beneath /folder1/myFolder and go 2 levels deep adding a link called: Home linked to the site's Home Page.


    back to top
    Social Bookmarks This macro generates bookmark links to the most popular social bookmarking sites such as Digg, Del.icio.us or Reddit, you can choose from more than 10 different sites.
    Available sites: blinkbits, blinklist, blogmarks, co.mments, connotea, del.icio.us, digg, google, newsvine, reddit, spurl, stumble upon, technorati, wists, yahoo.

    Macro Syntax:

    #socialBookmarks()
    

    Usage:

    The macro will generate the links to the chosen sites, given a list of the different bookmarking sites you wish to include.

    Example:

    #set ($socialBookmarksList = ['digg','delicious','yahoo','google','newsvine'])
    #socialBookmarks()



    back to top
    Generates a Tag Cloud Based on Used Content Tags This macro generates a list of tag links with all the tags used on the content of the given structures, every link generated is associated one of the following css classes [xSmallTag, smallTag, mediumTag, largeTag, xLargeTag] depending on the usage of the tag.

    Macro Syntax:

    #tagCloud(structureNames url maxNumberOfTags)
    Arguments: Optional Arguments:

    Example 1:

    #tagCloud(["White Papers", "Blogs", "Testimonial"] '/mypage.dot' 40)


    Example 2:

    #set($ignoredTags = ["tag1", "tag2"])

    #tagCloud(["White Papers", "Blogs", "Testimonial"] '/mypage.dot' 40)



    back to top
    Create a text area for a form. This is needed so you can create a text area in the backend of the dotcms.

    Macro Syntax:

    #textArea(name style)
    Arguments: Optional Arguments:

    Example 1:

    #textArea($myName "width:200px")


    Example 2:

    #set($id = "myID")

    #set($value = $myValue)

    #textArea("myName" "width:200px")



    back to top
    Title Generator This macro will create an image with the title sent as parameter.

    Macro Syntax:

       #titleImage('title')
    
    Arguments:

    Example:

       #set ($font = 'tahoma')
       #set ($size = '20')
       #set ($color = '30,30,30')
       #titleImage('Test Title')
    

    back to top
    Video Gallery This macro pulls all FLV files from a folder and displays a flash video player for each video. If a JPG image with the same name as the video file is provided it will be displayed as a thumbnail of the video.

    Macro Syntax:

    #videoGallery(url)
    Arguments: Optional:

    Usage:

    The macro will create a video gallery of all videos in the folder: /videos/.

    Example:

    #videoGallery('/videos/')

    Example2:

    #set($showVideoTitle = false)
    #set($showVideoDescription = false)
    #videoGallery('/videos/')
    
    This will display the video gallery with no titles and no descriptions for each video.

    Example3:

    #set($w = 200)
    #set($h = 200)
    #videoGallery('/videos/')
    
    This will display the video gallery with image thumbnails of 200 x 200.

    Example4:

    #set($galleriesToShow = 2)
    #videoGallery('/videos/')
    
    This will display the video gallery with only two videos at a time, it will display links to Next and Previous to view the rest.



    back to top
    Video Player: Play Video in a Flash Video Player You can provide this macro a URL to a .flv file and it will provide a player for your video.

    Macro Syntax:

    #videoPlayer(url)
    Arguments: Optional Parameters:

    Usage:

    The macro will play the video within an embedded flash player

    Example:

    #videoPlayer('/global/videos/myvideo.flv')


    Example2:

    #set($width = '500')
    #set($height = '500')
    #set($autoPlay = 'true')
    #set($backgroundColor = '#000000')
    #set($scale = 'default')
    #videoPlayer('/global/videos/myvideo.flv')
    



    "" ""