In the HTML template for my Component I need to write out the TCM URI of the Component Template:
<!-- Start Component Presentation: {"ComponentID" : "@@Component.ID@@",
"ComponentTemplateID" : "@@ComponentTemplate.ID@@" } -->
But unfortunately ComponentTemplate.ID
doesn't exist.
How can I access the Component Template ID from within my Component DWT?
I'm afraid you'll have to write a C# TBB (fragment or assembly):
TcmUri templateId = engine.PublishingContext.ResolvedItem.Template.Id;
if (templateId.ItemType == ItemType.ComponentTemplate) {
Item item = package.CreateStringItem(ContentType.Text, templateId.ToString());
package.PushItem("ComponentTemplateID", item);
}
You can only access the ComponentTemplate.ID from within a Page DWT layout...
Add a "ComponentTemplateID" parameter to the Template Invocation in the compound template. You can then access this in the same way as package variables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With