BuiltInFunctionsForUseInHtmlTemplates - TridionPractice/tridion-practice GitHub Wiki

Introduction

These are the built-in DWT functions as of Tridion 2011 SP1:

  • StringLength(object obj)
  • GetBinaryInfo()
  • GetFieldMetadata(string fieldName)
  • GetFieldMetadata(string fieldName, bool isMetaDataField)
  • RenderComponentField(string fieldExpression, int fieldIndex, bool htmlEncodeResult, bool resolveHtmlAsRTFContent)
  • RenderComponentField(string fieldExpression, int fieldIndex, string value, bool htmlEncodeResult, bool resolveHtmlAsRTFContent)
  • RenderComponentField(string fieldExpression, int fieldIndex)
  • RenderComponentField(string fieldExpression, int fieldIndex, string value)
  • RenderComponentPresentation()
  • RenderComponentPresentation(string componentUri, string templateUri)
  • SetRenderContextVariable(object name, object value)
  • CollectionLength(string expression)

They are all documented in the TOM.NET CHM. You can find them by looking for the members of the BuiltInFunctions class.

Example Output

I've run them on a Component with this XML:

<Content xmlns="uuid:4acb40fc-0a11-4c6e-aa28-03f889524613"><br>
  <Image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="tcm:1-98" xlink:title="!Halo3BestSeller"></Image>
  <ItemLink xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="tcm:1-97" xlink:title="Halo3"></ItemLink>
</Content>

And found the following outputs:

StringLength(object obj)
------------------------
StringLength("fixed value")=11
StringLength(Component.Title)=15
StringLength(Title)=15

GetBinaryInfo()
---------------
GetBinaryInfo()=

GetFieldMetadata(string fieldName)
----------------------------------
GetFieldMetadata("Image")=Name: Image
Description: Image Width: 250px Height : 250px
CustomUrl: 
MinOccurs: 1
MaxOccurs: 1

GetFieldMetadata("ItemLink")=AllowMultimediaLinks: False
 Name: ItemLink Description: ItemLink CustomUrl: 
 MinOccurs: 1
 MaxOccurs: 1
 
GetFieldMetadata("NonExistentField")=
 
GetFieldMetadata(string fieldName, bool isMetaDataField)
--------------------------------------------------------

GetFieldMetadata("ItemLink", false)=AllowMultimediaLinks: False
 Name: ItemLink Description: ItemLink CustomUrl: 
 MinOccurs: 1
 MaxOccurs: 1
 
GetFieldMetadata("ItemLink", true)=     

SetRenderContextVariable(object name, object value)
---------------------------------------------------

SetRenderContextVariable("Thanks", "Giving")=

CollectionLength(string expression)
-----------------------------------
CollectionLength("Component")=1
CollectionLength("Image")=1
CollectionLength("Image.Values")=1
CollectionLength("ItemLink.Values")=1
CollectionLength("Component.Properties")=0

I skipped all the RenderComponentField and RenderComponentPresentation overloads, since those are familiar to most people already. GetBinaryInfo didn't generate output above, since this was a normal Component. On a multimedia component, it gives:

 GetBinaryInfo()
 ------------------
GetBinaryInfo()=IsExternal: False
 Filename: haloBestSeller.jpg
 FileSize: 21838
 UploadFromFile: 
 MimeType: image/jpeg
 Title: Jpeg image
 CreationDate: 1/1/0001 12:00:00 AM
 RevisionDate: 1/1/0001 12:00:00 AM
 AllowedActions: Edit, View, Delete
 DeniedActions: None
 LoadState: FullyLoaded 
 LoadFlags: None
 IsEditable: True
⚠️ **GitHub.com Fallback** ⚠️