Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Tridion ShowTemplateSource Custom Page
<%
' Author: Robert Curlette
' Date updated: 15 March, 2012
Option Explicit
Response.Buffer = true
' Get All CT Source
Dim objTDSE : set objTDSE = CreateObject("TDS.TDSE")
Dim templateRootFolder
dim ctFolderUri, tbbFolderUri, ptFolderUri
ctFolderUri = "tcm:4-23-2" ' Component Template Folder
tbbFolderUri = "tcm:4-832-2" ' TBB Folder
ptFolderUri = "tcm:4-24-2" ' Page Template Folder
Dim pageUri : pageUri = "tcm:1-1-64"
if (Request.QueryString("folder") <> "") then
templateRootFolder = Request.QueryString("folder")
set templateRootFolder = objTDSE.GetObject(templateRootFolder, 1)
LoopThroughTemplates(templateRootFolder)
elseIf (Request.QueryString("page") <> "") then
pageUri = Request.QueryString("page")
Dim page: set page = objTDSE.GetObject(pageUri, 1)
LoopTemplatesOnPage(page)
set page = nothing
else
' show links to folders
%>
<html>
<head>
<style>
a{padding-left: 10px}
</style>
</head>
<body>
<div>
<a href="?folder=<% Response.Write(ctFolderUri) %>">Component Templates</a>
<a href="?folder=<%=tbbFolderUri %>">Page Templates</a>
<a href="?folder=<%=ptFolderUri%>">Template Building Blocks</a>
<a href="?page=<%=pageUri%>">Page</a>
</div>
</body>
</html>
<%
end if
Function LoopTemplatesOnPage(page)
Dim componentPresentation
for each componentPresentation in Page.ComponentPresentations
ShowTemplateSource(componentPresentation.ComponentTemplate)
next
End Function
Function LoopThroughTemplates(folder)
Dim objItem
Dim items : set items = folder.GetItems()
for each objItem in items
if (objItem.ItemType = 2) then
LoopThroughTemplates(objItem)
else
ShowTemplateSource(objItem)
end if
next
Set items = nothing
End Function
Sub ShowTemplateSource(template)
Dim seperator: seperator = vbcrlf & vbcrlf & "________________________________________________________________________________________________________________________________" & vbcrlf
Response.Write seperator & template.Title & "|" & template.ID & vbcrlf & vbcrlf & template.Content
Response.flush
End Sub
set templateRootFolder = Nothing
set objTDSE = Nothing
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.