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(200, "Alternate text") %>
• | Returns the image tag of avatar contained in the AvatarGuid field of the currently transformed group, with maximum sidesize 200 px. Alt tag will be Alternate text. |
<%# 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, 150 , "Alternate text") %>
• | Returns image tag of avatar with ID 1, with maximum sidesize 200 px, maximum width and height 150 px, the alt parameter 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(200, "Alternate text") %>
• | Returns image tag of avatar contained in the AvatarGuid field of the currently transformed user, with maximum sidesize 200 px. Alt tag will be Alternate text. |
<%# GetUserAvatarImage(1, 1, 200, "Alternate text") %>
• | Returns image tag of avatar with ID 1, of user with ID 1, with maximum sidesize 200 px. Alt tag will be Alternate text. |
<%# GetUserAvatarImage(1, 1, 200, 150, 150 , "Alternate text") %>
• | Returns image tag of avatar with ID 1, of user with ID 1, with maximum sidesize 200 px, maximum width and height 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. |
<%# GetDocumentUrlForFeed() %>
• | This method is used in transformations of RSS and Atom web parts. It returns URL of the rendered document using the GetDocumentUrl() method and adds the feed=<feed_name> querystring parameter to the URL; the feed name is taken from the Feed name web part property. |
• | Please note: as the 'feed' querystring parameter is added when this method is used, please use a different parameter name in the Feed querystring key property of the RSS or Atom web parts in this case. |
<%# GetFileUrl("ProductPhoto") %>
• | Inserts URL of the file stored in the column of the given name. |
<%# GetFileUrl("NewsPhoto1.jpg", "28") %>
• | Inserts URL of the attachment with name specified in the first parameter of the document with ID specified by the second one. |
<%# GetAttachmentUrl("NewsPhoto1.jpg","/News/Your-first-news") %>
• | Inserts URL of the attachment with name specified in the first parameter of the document with nodeAliasPath specified by the second one. This method returns the same URL as GetFileUrl, but needn't load the whole document, which results in better performance. |
<%# 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". |
Microsoft SharePoint
<%# SplitSharePointField((string)Eval("ows_FileRef"),1)) %>
• | Helper function for splitting combined fields returned by SharePoint. E.g. ows_LastModified="1;#2009-03-17T10:32:17Z. The first parameter is the original combined field, the second is the index of the returned part. |
<%# GetSharePointFileUrl("tester4", SharePointFunctions.SplitSharePointField((string)Eval("ows_FileRef"),1)) %>
• | Returns URL link to get specified document or picture from the SharePoint server. The first parameter is the SharePoint server URL, the second one is the path and name of the document to download. |
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. |
Smart search
<%# SearchResultUrl(true) %>
• | Returns URL to the document; the attribute (bool absolute) indicates if the returned URL should be absolute. |
<%# SearchHighlight("some search result text","<span style=\"background-color: #FEFF8F\">","</span>") %>
• | Wraps the text entered in the first attribute by the tags specified by the other two attribute. |
<%# GetSearchImageUrl("~/App_Themes/Default/Images/CMSModules/SmartSearch/no_image.gif", 90) %>
• | Returns URL of the current search result's image; the first attribute specifies URL returned in no image found, the second one specifies the maximal side size to which the image will be resized. |
<%# GetSearchValue(string columnName) %>
• | Returns specified column's value for the current search result. |
Syndication
<%# GetAtomDateTime(object dateTime) %>
• | Gets time for Atom feeds (according to RFC 3339) from the DateTime object. |
<%# GetRSSDateTime(object dateTime) %>
• | Gets time for RSS feeds (according to RFC 822) from the DateTime object. |
<%# GetProductUrlForFeed(object skuGUID, object skuName, object siteName) %>
• | Returns URL of the specified product with the feed querystring parameter appended. |
<%# GetDocumentUrlForFeed() %>
• | Returns URL of the currently rendered document with the feed querystring parameter appended. |
<%# GetForumPostUrlForFeed(object postIdPath, object forumId) %>
• | Returns URL of the specified forum post with the feed querystring parameter appended. |
<%# GetMediaFileUrlForFeed(object fileGUID, object fileName) %>
• | Returns URL of the specified media file with the feed querystring parameter appended. |
<%# GetMessageBoardUrlForFeed(object documentIdObj) %>
• | Returns URL of the specified message board with the feed querystring parameter appended. |
<%# GetBlogCommentUrlForFeed(object documentIdObj) %>
• | Returns URL of the specified message board with the feed querystring parameter appended. |
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:
• | GroupContextMenu.ascx |
• | UserContextMenu.ascx |
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> |