Macros available in the dotCMS system
Macro Syntax:
#addThis(accountID)
Usage:
Example 1:
#addThis('dotmarketingAddThis')
Example 2:
#set($addthis_logo ='http://www.mysite.com/global/images/logo.gif') #set($addthis_logo_background='EFEFEF') #set($addthis_logo_color='666666') #set($addthis_brand='My Site') #set($addthis_options='delicious, digg, google, newsvine') #set($addthis_offset_top='10') #set($addthis_offset_left='10') #set($addthis_bookmark_name='My Link Page')
#addBrowserBookmark()
Example :
#buildRSS(channelTitle channelLink channelDescription list)
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)
#buildRSSFromContent(channelTitle channelLink channelDescription query titleField descriptionField)
#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')
comment($contentlet.inode)
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)
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)
View Tool Syntax:
$dateviewapi.friendly(date)
Usage: Use this to show the difference date and time between a string date (before the current date) and the current date.
Wed, 02 Apr 2008 16:23:14 +0000 #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)
Sat, 26 Apr 2008 16:23:14 +0000 #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)
Example 3:
Thu, 01 May 2008 16:23:14 +0000 #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)
Example 4:
Fri, 02 May 2008 14:20:00 +0000 #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)
Example 5:
Fri, 02 May 2008 17:10:00 +0000 #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)
detailPageLink($content)
Usage: Use this macro to get the detail page for a piece of content
Example 1: #set($linkTitle = 'My Title') #detailPageLink($content)
#getRating(content_identifier)
Example:
#getRating($content.identifier)
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.
#ticker()
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.
#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") #set ($fgcolorDescription = "#AAAAAA") #set ($bgcolorDescription = "#ffffff") #set ($tickerSourceCode = "/my_velocity_files/my_ticker.vtl") #ticker($titleField)
<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>
#crumbTrail()
Usage: The crumbtrail builder will create an unordered list of links, starting from the site root or "Home Page". It will then use the folder names for folders, build the path to the current page, and then display the page title as the last link. The resulting html can be easily formatted by wrapping it in a <div> tag and assigning it appropiate css styles.
<div id="crumbtrail"> #crumbTrail() </div>
#set($homePath = '/about/') <div id="crumbtrail"> #crumbTrail() </div>
<ul> <li><a href="/about/">Home</a></li> <li><a href="/athletics/">Athletics</a></li> <li><a href="/athletics/news/">News</a></li> <li>News Listing</li> <-- No Link for current page </ul>
#pullTrackbacks(identifier)
#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
<img src="/resize_image?[[path] or [identifier]] &[ [[height] and/or [width]] or [[maxh] and [maxw]] ]">
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> " >
<img src="/resize_image?path=/images/image.jpg&maxw=120&maxh=130"> <img src="/resize_image?id=91&maxw=120&maxh=130"> <img src="/resize_image?path=/images/image.jpg&w=80&h=80"> <img src="/resize_image?id=91&w=80&h=80"> <img src="/resize_image?path=/images/image.jpg&w=80"> <img src="/resize_image?id=91&w=80"> <img src="/resize_image?path=/images/image.jpg&h=80"> <img src="/resize_image?id=91&h=80">
<img src="/thumbnail?id=[identifier]&[ [[height] and/or [width]] or [[r] and [g] and [b]] ]">
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> " >
<img src="/thumbnail?id=91&w=120&h=130"> <img src="/thumbnail?id=91&w=120"> <img src="/thumbnail?id=91&h=130"> <img src="/thumbnail?id=91&w=120&h=130&r=200&g=100&b=50">
#decrypt('string to decrypt')
#encrypt('website@dotcms.org') #decrypt($encryptedStr) This is the decrypted value = $decryptedStr
#encrypt('string to encrypt')
#encrypt('website@dotcms.org') #set ($to = $encryptedStr)
#events('from' 'to')
#events('1/1/2006' '2/1/2006')
#getSQLResults('select * from table')
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.
#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
#addToFavorites()
#set($addFavoritesLabel = 'Add to My Favorites') #set($removeFavoritesLabel = 'Remove from My Favorites') #addToFavorites()
#getFavorites()
#fileRepository('path')
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.
#fileRepository('/resources/documentation')
#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 = "/contentAsset/resize-image/${file.identifier}/fileAsset&w=178") #end Another example of code for /application/file_repository.vtl could be like this:
#linkRepository('path')
Usage: The repository will show a list of links.
#linkRepository('/resources/documentation')
#set($linkRepositorySourceCode = '/application/file_repository.vtl') #linkRepository('/documentation/repository') And the /application/file_repository.vtl file could look like this
#getContent(contentIdentifier)
#set($id = $request.getParameter("id")) #if($id) #getContent($id) #end My title is $content.title
$googleapi.searchGoogleMini(client, collection, subcollection, query, metaquery, start, num, autoFilter)
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
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
#set($searchObj = $googleapi.searchGoogleMini("default_frontend", "Main_Site", "", "Knight", "", 0, 100, false)) Search Summary Total Search time: $searchObj.searchTime Query: $searchObj.query From Index: $searchObj.fromIndex To Index: $searchObj.toIndex Estimated Total: $searchObj.estimatedTotal Has Next Results Page: $searchObj.hasNextPage() Has Previous Results Page: $searchObj.hasPreviousPage() Estimated Total of Results: $searchObj.estimatedTotal #foreach($result in $searchObj.searchResults) Result Index: $result.resultIndex Identation Level: $result.identationLevel Title: $result.title Snippet: $result.snippet Result URL: $result.resultURL General Rating Relevance: $result.generalRatingRelevance Mime Type: $result.mimeType Additional Search Details: $result.additionalSearchDetails Meta Tags Fields: $result.metaTagsFields #end
$googleapi.searchGoogleCustom(client, query, start, num, autoFilter)
Usage: Use this to pull search results from a google custom search, to make this web api work you have to setup the variables GOOGLE_CUSTOM_SEARCH_URL and GOOGLE_CUSTOM_SEARCH_CSEID on the dotmarketing.config.properties file pointing to the google custom search url like GOOGLE_CUSTOM_SEARCH_URL=http://www.google.com and GOOGLE_CUSTOM_SEARCH_CSEID=xxxxxxxxxxxxxxxxxxxxx:yyyyyyyyyyy 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 params - Hashmap with param names and values; contextTitle - String with the context title; 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
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 language - Language associated to the result label - Label associated to the result documentCacheSize - Document Cache Size associated to the result documentCacheId - Document Cache Id associated to the result
#set($searchObj = $googleapi.searchGoogleCustom("", "Knight", 0, 100, false)) Search Summary Total Search time: $searchObj.searchTime Query: $searchObj.query #foreach($param in $searchObj.params) Param Name: $param.key #foreach($paramValue in $param.value) $paramValue.key: $paramValue.value #end #end From Index: $searchObj.fromIndex To Index: $searchObj.toIndex Estimated Total: $searchObj.estimatedTotal Has Next Results Page: $searchObj.hasNextPage() Has Previous Results Page: $searchObj.hasPreviousPage() Estimated Total of Results: $searchObj.estimatedTotal #foreach($result in $searchObj.searchResults) Result Index: $result.resultIndex Identation Level: $result.identationLevel Title: $result.title Snippet: $result.snippet Result URL: $result.resultURL General Rating Relevance: $result.generalRatingRelevance Mime Type: $result.mimeType Additional Search Details: $result.additionalSearchDetails Meta Tags Fields: $result.metaTagsFields #end
#getFilesFromFS('path')
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.
#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
#loginForm()
Example: using the optional parameters. This example shows a "Create New Account" link under the Login button
#set($loginFormShowRegistrationLink = true) #set($loginFormRegistrationLinkText = "Create new account") #loginForm()
#googleMap($key)
Example: Using the address to display the location.
#set($zoomControl = false) #set($typeControl = false) #set($width = 700) #set($height = 400) #set($zoom = 10) #set($address = 'New York, NY') #set($key= 'ABQIAAAAD2HtMh5r6mfecenHsTsY4hQg63Lr_pVOuAxOwcwgB1dTWzIhpBSFkfJ3i9-I1-cz0qscObKevYORqw') #googleMap($key)
Example 2: Using the latitude and logitude to display the location.
<!-- Set the latitude --> #set($lat = '37.4419') <!-- Set the longitude --> #set($lng = '-122.1419') <!-- Set the zoom of the map --> #set($zoom = 10) #set($key= 'ABQIAAAAD2HtMh5r6mfecenHsTsY4hQg63Lr_pVOuAxOwcwgB1dTWzIhpBSFkfJ3i9-I1-cz0qscObKevYORqw') #googleMap($key)
#googleMapDirections($from,$to,$key)
#set($zoomControl = false) #set($typeControl = false) #set($width = 700) #set($height = 400) #set($mapAlign = 'top') #set($map_id_directions = 'mapCanvas1') #set($text_id_directions = 'textCanvas1') #set($from = 'Los Angeles, CA') #set($to = 'New York, NY') #googleMapDirections($from,$to,$key) <a href="${urlForPrint}">Print Mode</a>
#mailingList()
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==
#mediaGallery('/thefolder')
#mp3Player('path')
#mp3Player('/path/to/mp3s/file.mp3')
#mp3Player('/path/to/mp3s/playlist.xml')
The file /path/to/playlist.xml needs to generate the following format: http://$!{host.getHostname}/mp3s/file1.mp3 File Creator 1 File Title #1 Other http://$!{host.getHostname}/mp3s/file1.jpg http://$!{host.getHostname}/mp3s/file2.mp3 File Creator 2 File Title #2 Other http://$!{host.getHostname}/mp3s/file2.jpg http://$!{host.getHostname}/mp3s/file3.mp3 File Creator 3 File Title #3 Other http://$!{host.getHostname}/mp3s/file3.jpg
#mp3PlayerButton('song_url')
#mp3PlayerButton('/path/to/mp3s/example.mp3')
#mp3PlayerButton('/path/to/playlist.xml')
#mp3PlayerExtended('song_url')
#mp3PlayerExtended('/path/to/mp3s/example.mp3')
#myGroups($user)
#set($myGroupTitle= "<b>${user.fullName} Groups</b>") #myGroups($user)
<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>
#navigation(startLevel levelsToShow)
Syntax:
<div id="topNav"> #navigation(1,1) </div>
<div id="leftNav"> #navigation(2,2) </div>
<div id="leftNav"> #set($menuSpans = true) #navigation(2,2) </div>
<div id="leftNav"> #set($openAllLevels=true) #navigation(2,2) </div>
<div id="leftNav"> #set ($navigationSourceCode = '/my_velocity_files/my_navigation.vtl') #navigation(2,2) </div>
#pageContent('query' 'sort by' '# per page' '# current page')
#pageContent('+type:content +live:true +structureInode:5' 'date1' '5' '1') #foreach($content in $list) title: $!content.contentTitle summary: $!content.NewsSummary #end
#pdfExport()
Example with optional parameters:
#set($pdfFileName='My PDF Title') #set($pdfExportIcon='/html/images/icons/pdf.gif') #set($pdfExportAltText='Create PDF document') #pdfExport()
#permalink(identifier)
#permalink('12345')
Example2:
#set($permalinkDetailPage='78945') #permalink('12345')
Example3:
#set($permalinkTitle ="The Title") #permalink('12345')
#subscribe()
#trackback(identifier)
#trackback('12345')
#photoCarrousel (photoList photoDimensions)
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)
#photoGallery('/thefolder')
#photoGallery('/photo_galleries')
#printAverageRating(content_identifier)
#printAverageRating($content.identifier)
#printNumberOfVotes(content_identifier)
#printNumberOfVotes($content.identifier)
#poll('questionId')
#poll('')
#poll('123')
#set($allowViewResults = true)#poll('123')
Example4:
#set ($portletGroupIds = $contents.getEmptyList())#set ($_dummy = $portletGroupIds.add('12345'))#poll('')
#pullRSSFeed('url')
#set($rssFilter = ['dotcms','dotmarketing'])#set($rssTotal = 10)#pullRSSFeed('http://somesite/topnews.rss')#foreach($content in $list) title: $!content.title description: $!content.description#end
#pullContent('query' '# results' 'sort by')
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
#pullRelatedContent('relationship name' 'content inode' 'limit' 'sort by')
Example 1: This pulls a list of up to 100 content related to content with identifier 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 identifier 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
#randomImage (path)
#set ($path = '/global/images/') #randomImage($path) <img src="/resize_image?inode=$!{image.inode}&w=911&h=322" alt="Top Banner" width="911" height="322" />
#selectedInode()
#sendtofriend (articleText)
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!!!')
Example: This example call the macro with a template and with some custom parameters
<!--Create the hashmap--> #set($parameters = $contents.getEmptyMap()) <!--Set the parameters--> #set($dummy = $parameters.put('eventId',$eventId)) #set($dummy = $parameters.put('eventTitle',$content.title)) #set($dummy = $parameters.put('eventSubtitle',$content.subtitle)) #set($dummy = $parameters.put('eventDescription',$content.description)) #set($dummy = $parameters.put('eventImage',$content.largeImage)) #set($dummy = $parameters.put('eventStartDate',$UtilMethods.dateToHTMLDate($content.startDate,'hh:mm a'))) <!--Set the template--> #set($emailTemplate = "/calendar/sendfriendemailtemplate.dot") <!--Call the macro--> #set($sendToFriendStyle = "display:inline;") #sendtofriend('This is a Send To Friend test!!!')
#sitemap()
Usage: Use this macro if you want to add a site map for your whole site.
#siteMapFolder(2,2,'/folder1/myFolder')
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.
#set($reverseOrder = true) #siteMapFolder(2,2,'/folder1/myFolder')
#set($showHome = true) #siteMapFolder(2,2,'/folder1/myFolder')
#slideshow(title)
Usage: Use this macro if you want to add a flash slide show of a set of related images.
#slideshow('Slide Show Content Title')
#socialBookmarks()
#set ($onlyIcons = "true")
#set ($socialBookmarksList = ['digg','delicious','yahoo','google','newsvine'])
#set ($socialBookmarksShareIcon = "/test/bookmark_icon.gif")
#set ($socialBookmarksSourceCode = '/my_velocity_files/my_bookmarks.vtl')
#submitContent('Structure name')
#set($defaultSummary= 'Test Summary')
#set($News_Comments= ['1234','9876'])
Usage: Use this macro if you want to add a form to create a contentlet for a particular structure, the macro, will add a form to add new contentlet.
Example 1: This example generate a News content.
#submitContent("News")
Example 2: This example generate a News content with: image captha validation and a workflow task, modify the default value for the title field and add two required relationship to the contentlet with the comment structure.
#set($contentUseCaptcha = true) #set($contentModeration= 'Report User') #set($defaultTitle = 'TEST TITLE') #set($News-Comments = ['321229','321231']) #submitContent("News")
Example 3: This example generate a News content with: audio captcha validation, content auto publish, showing only the required fields, hidden the info, test and photo fields, and modifying the default description field value,.
#set($contentUseCaptcha = true) #set($contentUseAudioCaptcha = true) #set($contentAutoPublish = true) #set($showOnlyRequiredFields = true) #set($dontShowFields = ['info','test','photo']) #set($defaultDescription = 'TEST Description') #submitContent("News")
#tagCloud(structureNames url maxNumberOfTags)
#tagCloud(["White Papers", "Blogs", "Testimonial"] '/mypage.dot' 40)
#set($ignoredTags = ["tag1", "tag2"])
#textArea(name style)
#textArea($myName "width:200px")
#set($id = "myID")
#set($value = $myValue)
#textArea("myName" "width:200px")
#titleImage('title')
#set ($font = 'tahoma') #set ($size = '20') #set ($color = '30,30,30') #titleImage('Test Title')
#set ($font = 'tahoma') #set ($size = '20') #set ($color = '30,30,30') #set ($background = "transparent") #titleImage('firstString&secondString')
#set ($font = 'tahoma') #set ($size = '20') #set ($color = '30,30,30') #set ($background = "255,255,255") #titleImage('firstString')
#videoGallery(url)
#videoGallery('/videos/')
#set($showVideoTitle = false) #set($showVideoDescription = false) #videoGallery('/videos/')
#set($w = 200) #set($h = 200) #videoGallery('/videos/')
#set($galleriesToShow = 2) #videoGallery('/videos/')
#videoPlayer(url)
#videoPlayer('/global/videos/myvideo.flv')
#set($width = '500') #set($height = '500') #set($autostart = 'true') #set($backgroundColor = '#000000') #set($scale = 'default') #videoPlayer('/global/videos/myvideo.flv')