Take the 2-minute tour ×
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
what do you want to achieve here? –  Raj Kumar Aug 19 at 13:04
    
I just want to retrieve the Title of the templates. –  Manish Mehmood Aug 19 at 13:08
    
Manish - can you post an example of what you've tried or mention the documentation you've glanced at? –  Dylan .. Mark Saunders Aug 19 at 13:47

1 Answer 1

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]".

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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