Sign In
Macros
Please find the list of macros below. You can also jump to a section using the following links:
ApplicationPath
Syntax:{%applicationpath%}
Returns:UrlHelper.GetApplicationPath().TrimEnd('/') - Application path
to clipboard
AppPath
Syntax:{%apppath%}
Returns:UrlHelper.GetApplicationPath().TrimEnd('/') - Application path
to clipboard
CurrentCulture
Syntax:{%currentculture%}
Returns:CultureHelper.GetPreferredCulture() - Current culture
to clipboard
CurrentDate
Syntax:{%currentdate%}
Returns:DateTime.Now.ToShortDateString()
to clipboard
CurrentDateTime
Syntax:{%currentdatetime%}
Returns:DateTime.Now
to clipboard
CurrentTime
Syntax:{%currenttime%}
Returns:DateTime.Now.ToShortTimeString()
to clipboard
CurrentUrl
Syntax:{%currenturl%}
Returns:UrlHelper.CurrentURL - Current URL (new in 5.5)
to clipboard
Domain
Syntax:{%domain%}
Returns:UrlHelper.GetCurrentDomain() - Domain
to clipboard
EmptyString
Syntax:{%EmptyString%}
Returns:String.Empty
to clipboard
Ip
Syntax:{%ip%}
Returns:HTTPHelper.GetUserHostAddress() - Client's IP address
to clipboard
Now
Syntax:{%now%}
Returns:DateTime.Now
to clipboard
Pi
Syntax:{%Pi%}
Returns:Math.PI
to clipboard
Zero
Syntax:{%Zero%}
Returns:0
Example:{%Zero|(add)5%}
to clipboard
CMSContext.CurrentAttachment
Syntax:{%cmscontext.currentattachment%}
to clipboard
CMSContext.CurrentDocument
Syntax:{%cmscontext.currentdocument%}
to clipboard
CMSContext.CurrentDocumentCulture
Syntax:{%cmscontext.currentdocumentculture%}
to clipboard
CMSContext.CurrentDocumentOwner
Syntax:{%cmscontext.currentdocumentowner%}
to clipboard
CMSContext.CurrentDocumentParent
Syntax:{%cmscontext.currentdocumentparent%}
to clipboard
CMSContext.CurrentPageInfo
Syntax:{%cmscontext.currentpageinfo%}
to clipboard
CMSContext.CurrentSite
Syntax:{%cmscontext.currentsite%}
to clipboard
CMSContext.CurrentTemplate
Syntax:{%cmscontext.currenttemplate%}
to clipboard
CMSContext.CurrentUser
Syntax:{%cmscontext.currentuser%}
to clipboard
CommunityContext.CurrentFriend
Syntax:{%communitycontext.currentfriend%}
to clipboard
CommunityContext.CurrentFriendship
Syntax:{%communitycontext.currentfriendship%}
to clipboard
CommunityContext.CurrentGroup
Syntax:{%communitycontext.currentgroup%}
to clipboard
ECommerceContext.CurrentCurrency
Syntax:{%ecommercecontext.currentcurrency%}
to clipboard
ECommerceContext.CurrentCustomer
Syntax:{%ecommercecontext.currentcustomer%}
to clipboard
ECommerceContext.CurrentCustomerCountry
Syntax:{%ecommercecontext.currentcustomercountry%}
to clipboard
ECommerceContext.CurrentCustomerState
Syntax:{%ecommercecontext.currentcustomerstate%}
to clipboard
ECommerceContext.CurrentExchangeRate
Syntax:{%ecommercecontext.currentexchangerate%}
to clipboard
ECommerceContext.CurrentProduct
Syntax:{%ecommercecontext.currentproduct%}
to clipboard
ECommerceContext.CurrentProductDepartment
Syntax:{%ecommercecontext.currentproductdepartment%}
to clipboard
ECommerceContext.CurrentProductInternalStatus
Syntax:{%ecommercecontext.currentproductinternalstatus%}
to clipboard
ECommerceContext.CurrentProductPublicStatus
Syntax:{%ecommercecontext.currentproductpublicstatus%}
to clipboard
ECommerceContext.CurrentProductSupplier
Syntax:{%ecommercecontext.currentproductsupplier%}
to clipboard
ECommerceContext.CurrentShoppingCart
Syntax:{%ecommercecontext.currentshoppingcart%}
to clipboard
ForumContext.CurrentForum
Syntax:{%forumcontext.currentforum%}
to clipboard
ForumContext.CurrentGroup
Syntax:{%forumcontext.currentgroup%}
to clipboard
ForumContext.CurrentPost
Syntax:{%forumcontext.currentpost%}
to clipboard
ForumContext.CurrentThread
Syntax:{%forumcontext.currentthread%}
to clipboard
MediaLibraryContext.CurrentMediaFile
Syntax:{%medialibrarycontext.currentmediafile%}
to clipboard
MediaLibraryContext.CurrentMediaLibrary
Syntax:{%medialibrarycontext.currentmedialibrary%}
to clipboard
PortalContext.ViewMode
Syntax:{%portalcontext.viewmode%}
to clipboard
SiteContext.CurrentUser
Syntax:{%sitecontext.currentuser%}
to clipboard
add
Syntax:|(add)<number>
Returns:Adds the value
to clipboard
append
Syntax:|(append)<string>
Returns:Appends (suffixes) the given string to the value
Example:{%Zero|(append)ABC%} returns 0ABC
to clipboard
clear
Syntax:|(clear)
Returns:Clears current value to produce empty result
to clipboard
contains
Syntax:|(contains)<string>
Returns:True if value contains given string
to clipboard
cos
Syntax:|(cos)
Returns:Cosine
Example:{%Something|(cos)%}
to clipboard
culture
Syntax:|(culture)<code>
Returns:Returns the value in specified culture
Example:{%SKUPrice|(culture)en-us%} writes the product price in an English culture formatting
to clipboard
default
Syntax:|(default)<value>
Returns:Default value (if value is not found)
Example:{%SKUPrice|N/A%} writes product price or N/A if the document is not a product
to clipboard
divide
Syntax:|(divide)<value>
Returns:Divides the value by the given number
Example:{%Something|(divide)3%}
to clipboard
encode
Syntax:|(encode)<true/false>
Returns:HTMLHelper.HTMLEncode
Example:{%DocumentName|(encode)true%} or {%DocumentName|(encode)%} writes the HTML encoded document name, such as Black & white
to clipboard
endswith
Syntax:|(endswith)<string>
Returns:True if value ends with given string
to clipboard
equals
Syntax:(equals)<value>
Returns:Returns “true” if the resolved value matches the given value, else returns “false”. Uses the (truevalue), (falsevalue) settings for the output.
Example:{%UserName|(equals)administrator%} writes true if the user is administrator
to clipboard
escape
Syntax:(operation)\|(operation)
Returns:Escapes the macro
Example:{%CurrentUserName|(append)\|(you)%}
to clipboard
falsevalue
Syntax:|(falsevalue)<value>
Returns:Output settings for the negative output of the comparisson
Example:{%UserName|(equals)administrator|(truevalue)Yes|(falsevalue)No%} writes No if the user is not administrator
to clipboard
format
Syntax:|(format)<format>
Returns:Formatted value
Example:{%SKUPrice|(format){0:f1}%} writes the product price with precision for one decimal place
to clipboard
getmatch
Syntax:|(getmatch)<regex>
Returns:Regex.Match
Example:{%CurrentDocument.DocumentName|(getmatch)[k-r]%} will result in "om" on "Home"
to clipboard
greaterthan
Syntax:|(greaterthan)<number>
Returns:True if current value is greater than given number
to clipboard
handlesqlinjection
Syntax:|(handlesqlinjection)
Returns:Resolver will handle the SQL injection of the result
to clipboard
jsescape
Syntax:|(jsescape)
Returns:Replaces quotes and \n (javascript escapes)
to clipboard
limitlength
Syntax:|(limitlength)<chars>
Returns:TextHelper.LimitLength
to clipboard
lowerthan
Syntax:|(lowerthan)<number>
Returns:True if current value is lower than given number
to clipboard
mappath
Syntax:|(mappath)
Returns:Maps the virtual path to the physical path
Example:Maps ~/Home.aspx to C:\Inetpub\wwwroot\KenticoCMS\Home.aspx
to clipboard
matches
Syntax:|(matches)<regex>
Returns:True if regular expression matched on the given value
to clipboard
multiply
Syntax:|(multiply)<number>
Returns:Multiplies the value
to clipboard
not
Syntax:|(not)
Returns:Negates current value
to clipboard
notequals
Syntax:|(notequals)<value>
Returns:Returns “false” if the resolved value matches the given value, else returns “true”. Uses the (truevalue), (falsevalue) settings for the output.
Example:{%UserName|(notequals)administrator%} – Writes false if the user is administrator
to clipboard
notrecursive
Syntax:|(notrecursive)
Returns:Explicitly disables the recursion of the macros
to clipboard
padleft
Syntax:|(padleft)<total width>, |(padleft)<total width>(with)<char>
Returns:Makes sure that the string has total width of characters, filling the blanks with space
Example:{%Zero|(add)5|(padleft)3(with)0%} returns 005
to clipboard
padright
Syntax:|(padright)<total width>, |(padright)<total width>(with)<char>
Returns:Makes sure that the string has total width of characters, filling the blanks with space
to clipboard
pow
Syntax:|(pow)<value>
Returns:Raises the first argument to the power of the second argument
Example:{%Something|(pow)2%}
to clipboard
prepend
Syntax:|(prepend)<string>
Returns:Prepends (prefixes) the given string to the value
Example:{%Zero|(prepend)ABC%} returns ABC0
to clipboard
regexreplace
Syntax:|(regexreplace)<regex>(with)<dest>
Returns:Replaces the source string with the destination string using regular expressions
to clipboard
replace
Syntax:|(replace)<src>(with)<dest>
Returns:Replaces the source string with the destination string
Example:{%CurrentDocument.DocumentName|(replace)e(with)er%} on "Home" will result in "Homer"
to clipboard
resolve
Syntax:|(resolve)
Returns:Resolves macros
to clipboard
resolvebbcode
Syntax:(resolvebbcode)<true/false>
Returns:Resolves the BB code in the result of the macro
Example:{%MessageText|(resolvebbcode)true%} or {%MessageText|(resolvebbcode)%} writes the resolved BB code such as conversion of [url]… to <a href="…
to clipboard
resolveurl
Syntax:|(resolveurl)
Returns:Resolves the virtual path or URL
Example:Converts ~/Home.aspx to /KenticoCMS/Home.aspx
to clipboard
saveas
Syntax:|(saveas)<key>
Returns:Saves current value to the selector (under current resolving context)
to clipboard
sin
Syntax:|(sin)
Returns:Sine
Example:{%Something|(sin)%}
to clipboard
sqlescape
Syntax:|(sqlescape)
Returns:Replaces ' with '' (SQL escapes)
to clipboard
sqrt
Syntax:|(sqrt)
Returns:Square root
Example:{%Something|(sqrt)%}
to clipboard
startswith
Syntax:|(startswith)<string>
Returns:True if value starts with given string
to clipboard
striptags
Syntax:|(striptags)
Returns:HTMLHelper.StripTags
to clipboard
substring
Syntax:|(substring)<start>, |(substring)<start>;<length>
Returns:The part of the string after the given index
Example:{%CurrentDocument.DocumentName|(substring)1;3%} on document "News" will give you "ews"
to clipboard
tan
Syntax:|(tan)
Returns:Tangent
Example:{%Something|(tan)%}
to clipboard
tobool
Syntax:(tobool)<default value>
Returns:Conversion to Boolean, uses the (truevalue), (falsevalue) settings as a result
Example:{?onlyvalid|(tobool)true?} writes false if onlyvalid querystring parameter is false, else returns true
to clipboard
todatetime
Syntax:(todatetime)<default value>
Returns:Conversion to DateTime, uses the (culture) settings
Example:{?targettime|(todatetime)?} converts the targettime query parameter to date time or DateTime.MinValue
to clipboard
todouble
Syntax:(todouble)<default value>
Returns:Conversion to Double (uses the culture settings)
Example:{?price|(todouble)10.2?} converts the price query parameter to double or 10.2
to clipboard
toguid
Syntax:(toguid)<default value>
Returns:Conversion to GUID
Example:{?userguid|(toguid)?} converts the userguid query parameter to Guid or Guid.Empty
to clipboard
toint
Syntax:(toint)<default value>
Returns:Converts the result to integer, if not successful, uses the default value.
Example:{?tagid|(toint)0?} writes the valid tagid from querystring or 0 if not valid
to clipboard
tolower
Syntax:|(tolower)<true>
Returns:Converts the result to lowercase
Example:{%DocumentName|(tolower)true%} or {%DocumentName|(tolower)%} writes black & white
to clipboard
toupper
Syntax:|(toupper)<true>
Returns:Converts the result to uppercase
Example:{%DocumentName|(toupper)true%} or {%DocumentName|(toupper)%} writes BLACK & WHITE
to clipboard
trim
Syntax:|(trim), |(trim)<chars>
Returns:Removes the white spaces on the beginning and end of the value
Example:{%EmptyString|(append)ABCD|(trim)AD%} returns BC
to clipboard
trimend
Syntax:|(trimend), |(trimend)<chars>
Returns:Does the trimming only on the end of the string
to clipboard
trimstart
Syntax:|(trimstart), |(trimstart)<chars>
Returns:Does the trimming only on the end of the string
to clipboard
truevalue
Syntax:|(truevalue)<value>
Returns:Output settings for the positive output of the comparisson
Example:{%UserName|(equals)administrator|(truevalue)Yes|(falsevalue)No%} writes Yes if the user is administrator
to clipboard
unresolveurl
Syntax:|(unresolveurl)
Returns:Unresolves the URL
to clipboard
urlencode
Syntax:|(urlencode)<true/false>
Returns:HttpUtility.UrlEncode
Example:{%DocumentName|(urlencode)true%} or {%DocumentName|(urlencode)%} writes the URL encoded document name, such as All%20items
to clipboard
Nested
Syntax:{%Something|(equals)Something|(truevalue){(1)%Something%(1)}%}
Returns:Nested macro
Example:{%DocumentName|(equals)Home|(truevalue){(1)%param%(1)}%}
to clipboard
Nested #2
Syntax:{%Something|(equals)Something|(truevalue){(1)%Something%(1)}%}
Returns:Nested macro
Example:{%DocumentMenuCaption|(equals)|(truevalue){(1)%DocumentName%(1)}|(falsevalue){(2)%DocumentMenuCaption%(2)}%}
to clipboard
Nested #3
Syntax:{%Something|(equals)Something|(truevalue){(1)%Something%(1)}%}
Returns:Nested macro
Example:{(1)%DocumentMenuCaption|(equals)|(truevalue){(2)%DocumentName%(2)}|(falsevalue){(3)%DocumentMenuCaption%(3)}%(1)}
to clipboard
Web part container title (nested)
Syntax:{%Something|(equals)Something|(truevalue){(1)%Something%(1)}%}
Returns:Nested macro
Example:{(1)%ContainerTitle|(equals)|(truevalue)|(falsevalue)<h2>{(2)%ContainerTitle%(2)}</h2>%(1)}
to clipboard

About me

Jeroen Furst 
  • Facebook
  • LinkedIn
  • RSS
  • Twitter

Kentico DevNet

IBL-Software

Sponsored links

Interview with Kentico

You have an old version of Adobe's Flash Player. Get the latest Flash player.
Kentico blogs and websites
Martin Hejtmanek - Kentico CTO
Thomas Robbins - Kentico product evangelist
Petr Vozak - Kentico team leader
Brian McKeiver - BizStream
Johnny Bubriski - Wakefly, Inc.
Bryan Soltis - Bit-Wizards
Kentico Developer - Reed Business Information
Kentico Solutions - Data, Inc.

My trees

Latest Kentico Knowledge Base Articles

Kentico Developer Posters

Kentico CMS 5.5 Macro Reference