4

I want to retrieve Template name against the legacy id of a template. for example "VB script" has legacy id 1

enter image description here

Jscript template has legacy id 2 and so on. I am using TemplateType property of the object of TemplateBuildingBlock class which returns integer value as legacy ID.

Is there any way to retrieve the title of template against the legacy ID of that template?

3
  • what do you want to achieve here?
    – Raj Kumar
    Aug 19, 2014 at 13:04
  • I just want to retrieve the Title of the templates. Aug 19, 2014 at 13:08
  • Manish - can you post an example of what you've tried or mention the documentation you've glanced at? Aug 19, 2014 at 13:47

1 Answer 1

3

One thing you can try doing is using the TDSE.GetListTemplateTypes() method. This will return an xml string that contains all of the template types. You could then search for the node that matches your ID, and get the Title attribute from that node.

The returned XML of GetListTemplateTypes will look something like:

<tcm:ListTemplateTypes xmlns:tcm="http://www.tridion.com/ContentManager/5.0">
  <tcm:Item ID="4" Name="CompoundTemplate" Title="Compound Template" MIMEType="text/x-tcm-compound" HasBinaryContent="false">
    <tcm:WebDavFileExtension ItemType="ComponentTemplate">tctcmp</tcm:WebDavFileExtension>
    <tcm:WebDavFileExtension ItemType="PageTemplate">tptcmp</tcm:WebDavFileExtension>
    <tcm:WebDavFileExtension ItemType="TemplateBuildingBlock">tbbcmp</tcm:WebDavFileExtension>
  </tcm:Item>
  <tcm:Item ID="3" Name="XSLT" Title="XSLT" MIMEType="text/xml" HasBinaryContent="false">
    <tcm:WebDavFileExtension ItemType="ComponentTemplate">tctx</tcm:WebDavFileExtension>
    <tcm:WebDavFileExtension ItemType="TemplateBuildingBlock">tbbx</tcm:WebDavFileExtension>
  </tcm:Item>
  <tcm:Item ID="5" Name="AssemblyTemplate" Title=".NET Assembly" MIMEType="application/x-tcm-assembly" HasBinaryContent="true">
    <tcm:WebDavFileExtension ItemType="TemplateBuildingBlock">tbbasm</tcm:WebDavFileExtension>
  </tcm:Item>
  <tcm:Item ID="6" Name="CSharpTemplate" Title="C# Code Fragment" MIMEType="text/x-tcm-csharpfragment" HasBinaryContent="false">
    <tcm:WebDavFileExtension ItemType="TemplateBuildingBlock">tbbcs</tcm:WebDavFileExtension>
  </tcm:Item>
  <tcm:Item ID="7" Name="DreamweaverTemplate" Title="Dreamweaver" MIMEType="text/x-tcm-dreamweaver" HasBinaryContent="false">
    <tcm:WebDavFileExtension ItemType="TemplateBuildingBlock">dwt</tcm:WebDavFileExtension>
  </tcm:Item>
  <tcm:Item ID="8" Name="RazorTemplate" Title="RazorTemplate" MIMEType="text/x-tcm-cshtml" HasBinaryContent="false">
    <tcm:WebDavFileExtension ItemType="TemplateBuildingBlock">cshtml</tcm:WebDavFileExtension>
  </tcm:Item>
  <tcm:Item ID="1" Name="VBScript" Title="VBScript [Legacy]" MIMEType="text/plain" HasBinaryContent="false">
    <tcm:WebDavFileExtension ItemType="ComponentTemplate">tcts</tcm:WebDavFileExtension>
    <tcm:WebDavFileExtension ItemType="PageTemplate">tpts</tcm:WebDavFileExtension>
    <tcm:WebDavFileExtension ItemType="TemplateBuildingBlock">tbbs</tcm:WebDavFileExtension>
  </tcm:Item>
  <tcm:Item ID="2" Name="JScript" Title="JScript [Legacy]" MIMEType="text/plain" HasBinaryContent="false">
    <tcm:WebDavFileExtension ItemType="ComponentTemplate">tcts</tcm:WebDavFileExtension>
    <tcm:WebDavFileExtension ItemType="PageTemplate">tpts</tcm:WebDavFileExtension>
    <tcm:WebDavFileExtension ItemType="TemplateBuildingBlock">tbbs</tcm:WebDavFileExtension>
  </tcm:Item>
</tcm:ListTemplateTypes>

Hope that helps!

UPDATE

Also added some vb code reference for you (or anyone else) if needed. The following will get the template type with id of 1, and output its title. If the code is horrid my apologies, my VBScript is a bit rusty.

[%
    Dim xmlDoc
    Dim xmlString
    Dim templateTypeNode
    Dim templateTypeName

    xmlString= TDSE.GetListTemplateTypes()
    Set xmlDoc = CreateObject("MSXML2.DOMDocument")
    xmlDoc.LoadXml(xmlString)

    Set templateTypeNode = xmlDoc.SelectSingleNode("/tcm:ListTemplateTypes/tcm:Item[@ID='1']")
    templateTypeName =  templateTypeNode.attributes.getNamedItem("Title").nodeValue 
%]
[%= templateTypeName %]

Should output "VBScript [Legacy]".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.