02C0A070D6AF47DC97EC8523E05AEE90
  • RedDot CMS Blog
  • 13.03.2017
  • EN

rdb: RenderTags – An Overview


Notice: This article is based on a late Release 10.2 and early Release 11.0 ... in the future, there will be additional articles with updates about all rendertags incl. Release 16 for WebSiteManagment (RedDot CMS) Server ;)


RenderTags can be used in many different ways. By using them one not only is able to read content from several places in the project you also can change and manipulate page rendering and use the render tag technology for your control structures.
The following list gives a overview and is meant to be an introduction into the functionality and use cases for RenderTags.

The most common use of RenderTags is probably the output of content:

<%!!
Context:CurrentPage.Elements.GetElement(std_elem).Value
!!%>

 

Manipulating the returned content

Only returning content might often be not of interest. This can be done by a reference or just the element placeholder itself. Hence here are a couple of ways to manipulate the render tag content output.

PadRight()
Return the content of an element with a maximum length of 15 characters

<%!!
Context:CurrentPage.Elements.GetElement(std_elem).Value.PadRight(Int:15)
!!%>

Substring()
Return the first 10 characters of a content element

<%!!
Context:CurrentPage.Elements.GetElement(std_elem).Value.Substring(Int:0, Int:10)
!!%>

Trim()
Return content and remove white space from beginning and end of string

<%!!
Context:CurrentPage.Elements.GetElement(std_elem).Value.Trim()
!!%>

Replace()
Return element content but replace parts of the string. In this example I replace “RedDot” with “OpenText”

<%!!
Context:CurrentPage.Elements.GetElement(std_elem).Value.Replace(RedDot,OpenText)
!!%>

ToUpper()
Return the output in UPPERCASE

<%!!
Context:CurrentPage.Elements.GetElement(std_elem).Value.ToUpper()
!!%>

ToLower()
Return the value of the string in lowercase

<%!!
Context:CurrentPage.Elements.GetElement(std_elem).Value.ToLower()
!!%>

ToString()
Change the output type to type “String()”

<%!!
Context:CurrentPage.Elements.GetElement(std_elem).Value.ToString()
!!%>

Length
Return the character length of returned value

<%!!
Context:CurrentPage.Elements.GetElement(std_elem).Value.Length
!!%>

HtmlEncode()
Return HTML encoded value of the element

<%!!
Escape:HtmlEncode(Context:CurrentPage.Elements.GetElement(std_elem).Value)
!!%>

HtmlDecode()
Return HTML decoded value of the element

<%!!
Escape:HtmlDecode(Context:CurrentPage.Elements.GetElement(std_elem).Value)
!!%>

 

Control output based on render tag queries

RenderTags are not only used to return element content.
It also can be used to check the value of an element and create several types of queries.

Equals()
Checks if two Strings are equal or not, return value is type of Boolean

<%!!
Context:CurrentPage.Elements.GetElement(std_elem).Value.Equals(STR)
!!%>

StartsWith()
Checks if the returned content starts with the given value (i.e. character) Return value is of type Boolean

<%!!
Context:CurrentPage.Elements.GetElement(std_elem).Value.StartsWith(STR)
!!%>

EndsWith()
Checks if the returned content ends with the given value (i.e. character) Return value is of type Boolean

<%!!
Context:CurrentPage.Elements.GetElement(std_elem).Value.EndsWith(STR)
!!%>

 

<If> and <else> render tag queries

These return values can be used as well as queries which are known from other programming languages.
Another way of controlling output for example are <if>- and <if>-<else>-queries

<IF>

<reddot:cms>
  <if>
    <query valuea="Context:CurrentPage.Elements.GetElement(std_elem).Value" operator="==" valueb="String:test">
      <htmltext>
        Value is "test"
      </htmltext>
    </query>
  </if>
</reddot:cms>

This IF-query can be enhanced by the ELSE-query which comes in handy when you need an SSL-Switch or you want to Skip levels in your navigation

<IF>-<ELSE>

<reddot:cms>
  <if>
    <query valuea="Context:CurrentPage.Elements.GetElement(std_elem).Value" operator="==" valueb="String:test">
      <htmltext>
        Value is "test"
      </htmltext>
    </query>
    <query type="else">
      <htmltext>
        Value is certainly NOT "test"
      </htmltext>
    </query>
  </if>
</reddot:cms>

 

In the Loop

Beside these two options RenderTags offer other solutions. One of those is the possibility to use RenderTags for the output of elements within or outside of structure elements. For example you can use those outside of navigation manager templates to return your project structure

foreach

<reddot:cms>
  <foreach itemname="item" object="Context:CurrentPage.SubIndexes" countername="counter">
    <htmltext>
      <%!! Store:counter !!%>. <%!! Store:item.Headline !!%><br />
    </htmltext>
  </foreach>
</reddot:cms>

 

Reading structure elements

Not only can this be used to return your navigation structure at any point of the project – you also can use it to return the structure elements (lists, anchors, container) of any page. Although – in Version 7.5.x – not in the right sort order.

foreach

<reddot:cms>
  <foreach itemname="item" object="Context:CurrentPage.Elements.GetElement(lst_elem).Value" countername="counter">
    <htmltext>
      <%!! Store:counter !!%>. <%!! Store:item.Headline !!%><br />
    </htmltext>
  </foreach>
</reddot:cms>

 

Undocumented and documented RenderTags

Beside those and the already described functions in the documentation there are a couple of others which aren’t documented (yet?). For example it is possible to return the name of a content class by using this

Template
Reading a content-class

<%!!
Context:CurrentPage.Template.Name
!!%>

RenderTags were quite new and a lot Open Text / RedDot CMS developers are used to ASP with VB.Net but these new tags are worth to have a look at because some of them can reach into parts of the project were you are stuck with your ASP code or you would have to use RQLs which can be slow down the editing process.
 

 

Disclaimer

Be aware of undocumented RenderTags, they might change with the next version of RedDot (oh, wait, there might be no next major version after version 10..) ok, they might change with the next hotfix and then you have to walk through your system and find the little buggers. We also don’t give any warranty for the code shown here, use it at your own risk.

 

Links

  • Credits for this collection go to Ingo from Shift8, who has wrote all this down in German
  • This is Phil McKenzies hardcore render tag article which will take you more than one step ahead the usual way of using RenderTags – Very nice read!
  • RenderTags to translate a site easily! A great article for international projects.
  • Allowing external links in your navigation Growing your navigation beyond the basic tree – Interesting approach by Adrian
       

Downloads

 

QuickLinks

 

Channel