The following expressions can be used in transformation code:
Community and membership
<%# GetAge(Eval("UserDateOfBirth"),"Unknown age") %>
• | Returns age according to day of birth given in first param. If day of birth is not set, returns "Unknown age". |
<%# GetGender(Eval("UserGender")) %>
• | Returns gender of given user. |
<%# GetGroupAvatarImage(1, 200, "Alternate text") %>
• | Returns image tag of avatar with ID 1, with maximum sidesize 200 px. Alt tag will be Alternate text. |
<%# GetGroupAvatarImage(1, 200, 150, 0 , "Alternate text") %>
• | Returns image tag of avatar with ID 1, with maximum sidesize 200 px, maximum width 150 px, alt param of image will be Alternate text. |
<%# GetGroupProfileUrl(CMS.Community.CommunityContext.CurrentGroup) %>
• | Returns url to profile of given group. |
<%# GetMemberProfileUrl(Eval("UserName")) %>
• | Returns url to member profile of given member. |
<%# GetUserAvatarImage(1, 200, "Alternate text") %>
• | Returns image tag of avatar with ID 1, with maximum sidesize 200 px. Alt tag will be Alternate text. |
<%# GetUserAvatarImage(1, 200, 150, 0 , "Alternate text") %>
• | Returns image tag of avatar with ID 1, with maximum sidesize 200 px, maximum width 150 px, alt param of image will be Alternate text. |
<%# GetUserProfileURL(CMSHelper.CMSContext.CurrentUser) %>
• | Returns url to profile of given user. |
Data
<%# DataItem %>
• | Gets the DataItem object. |
<%# DataItemIndex %>
• | Gets the data item index. |
<%# DataRowView %>
• | Gets the DataRowView of the record data. |
<%# DisplayIndex %>
• | Gets the data item display index. |
<%# DocumentCustomData["myproperty2"] %>
• | Gets document custom data value (culture specific). |
<%# EditableItems["mainText"] %>
• | Gets editable region value. |
<%# Eval("NewsTitle") %>
• | Displays value of the given field. |
<%# Eval("NewsTitle", true) %>
• | Displays value of the given field. If second param is true value will be HTML encoded. |
<%# GetEditableValue("mainText") %>
• | Gets editable region value. |
<%# NodeCustomData["myproperty1"] %>
• | Gets node custom data value. |
Date & time
<%# FormatDateTime(DateTime.Now, "MM/dd/yyyy HH:mm") %>
• | Formats given datetime according to given format. |
<%# GetCustomDateTime(DateTime.Now, "GreenwichMeanTime") %>
• | Returns date-time according to given time zone. |
<%# GetDateTime("NewsReleaseDate") %>
• | Returns date-time value. |
<%# GetDateTime("NewsReleaseDate", "MM/dd/yyyy HH:mm") %>
• | Returns date-time value in given format. |
<%# GetSiteDateTime(DateTime.Now) %>
• | Returns date-time according to site time zone. |
<%# GetUserDateTime(DateTime.Now) %>
• | Returns date-time according to current user time zone. |
Document links and URLs
<%# GetDocumentLink() %>
• | Inserts a complete HTML code of the link pointing to the rendered document. |
<%# GetDocumentLink(false) %>
• | Inserts a complete HTML code of the link pointing to the rendered document. Does not encode the document name. |
<%# GetDocumentUrl("NodeGUIDColumn", "NodeAlias") %>
• | Inserts URL of the specified document. |
<%# GetDocumentUrl() %>
• | Inserts URL of the rendered document. |
<%# GetFileUrl("ProductPhoto") %>
• | Inserts URL of the file stored in the column of the given name. |
<%# GetUrl("/News/News-1", null) %>
• | Gets the URL to specified document. |
<%# GetUrl("/News/News-1", null, "CorporateSite") %>
• | Gets the URL to specified document on a different site. |
Images
<%# GetImage("NewsTeaser") %>
• | Inserts a complete HTML code of the image stored in the column of the given name. |
<%# GetImage("NewsTeaser", 200) %>
• | Inserts a complete HTML code of the image stored in the column of the given name.Second param is maximal side size. |
<%# GetImage("NewsTeaser", 200, 100) %>
• | Inserts a complete HTML code of the image stored in the column of the given name with maximal size 200 x 100. |
<%# GetImage("NewsTeaser", 200, 200, 100) %>
• | Inserts a complete HTML code of the image stored in the column of the given name with maximal side size 200 and maximal size 200 x 100. |
<%# GetImage("NewsTeaser", 200, 200, 100, "image") %>
• | Inserts a complete HTML code of the image stored in the column of the given name with maximal side size 200 and maximal size 200 x 100. |
<%# GetImageByUrl("~/getfile/eb1b5175-d7e6-479e-a19e-dbd6be035c16/homepage.aspx") %>
• | Inserts a complete HTML code of the image given by url. |
<%# GetImageByUrl("~/getfile/eb1b5175-d7e6-479e-a19e-dbd6be035c16/homepage.aspx", 100, 200) %>
• | Inserts a complete HTML code of the image given by url with maximal size 100 x 200. |
<%# GetImageByUrl("~/getfile/eb1b5175-d7e6-479e-a19e-dbd6be035c16/homepage.aspx", 200) %>
• | Inserts a complete HTML code of the image given by url. Maximal side size will be 200. |
<%# GetImageByUrl("~/getfile/eb1b5175-d7e6-479e-a19e-dbd6be035c16/homepage.aspx",200, 100, 200, "image") %>
• | Inserts a complete HTML code of the image given by url with maximal side size 200 and maximal size 100 x 200, alternate text will be image. |
<%# IfImage("NewsTeaser", "It is an image", "It isn't an image") %>
• | If column "NewsTeaser" contains Guid of image returns "It is an image". |
Text
<%# EnsureMaximumLineLength("SomeVeryLongStringWithoutAnyBlankSpaces", 20) %>
Ensures line break of long uninterupted text (such as URL) after the number of characters given in the second parameter.
<%# HTMLEncode("Sample text <br />") %>
• | Encodes HTML tags in given text. |
<%# LimitLength("Some example long text", 10 , "...") %>
• | Limits length of text (in this example returns "Some ex..."). |
<%# RemoveDiscussionMacros("[quote]Sample example text[/quote]") %>
• | Remove all tips of discussion macros from text. |
<%# StripTags("Sample text <br />") %>
• | Removes HTML tags from text. |
Other
<%# GetAbsoluteUrl("~/Home.aspx") %>
• | Returns absolute URL of given relative URL. |
<%# GetBlogCommentsCount(23, "/Blogs/MyBlog/June-2008/Post1") %>
• | Gets number of comments of blog post with Document ID 23 and alias path /Blogs/MyBlog/June-2008/Post1. |
<%# GetBlogCommentsCount(23, "/Blogs/MyBlog/June-2008/Post1", true) %>
• | Gets number of comments of blog post with Document ID 23 and alias path /Blogs/MyBlog/June-2008/Post1; trackback posts are included in the result. |
<%# IfCompare(1, 2, "Two si bigger", "One is bigger") %>
• | Compares values of first and second params. |
<%# IfEmpty(Eval("ProductPhoto"), "no image", "<img src=\"" + Eval("ProductPhoto") + "\" />") %>
• | If ProductPhoto set, displays the image, else displays the text "no image". |
Context menus
When editing transformations displaying Users or Groups, you can enclose the transformation code within one of the following controls, which enables context menus after right-click on the selected user or group:
Users
<cms:usermenucontainer runat="server" ID="userMenuElem" MenuID="userContextMenu" Parameter='<%# Eval("UserID").ToString() %>' ContextMenuCssClass="UserContextMenu" >
... transformation code ...
</cms:usermenucontainer>
|
Groups
<cms:groupmenucontainer runat="server" ID="groupMenuElem" MenuID="groupContextMenu" Parameter='<%# Eval("GroupID").ToString() %>' ContextMenuCssClass="UserContextMenu" >
... transformation code ...
</cms:groupmenucontainer>
|
The code above displays the default context menu controls for users or groups. These controls are stored in <web project>\CMSAdminControls\ContextMenus:
You can also develop your custom controls for this purpose. In this case, you need to include the MenuControlPath parameter in the cms:usermenucontainer or cms:groupmenucontainer controls in the transformation and set its value to the path to your control:
<cms:groupmenucontainer runat="server" ID="groupMenuElem" MenuID="groupContextMenu" Parameter='<%# Eval("GroupID").ToString() %>' ContextMenuCssClass="UserContextMenu" MenuControlPath="~\CMSAdminControls\ContextMenus\MyGroupContextMenu.ascx" >
... transformation code ...
</cms:groupmenucontainer>
|
|