0

How to get the component template web dav url from tridion using C#.

After fetching that CT url passing to the folder object.

Right now i'm using the hard-coded path, but in the future it may won't work when port the items to different environment.

1
  • Could you make the question a bit more descriptive? please specify the scenario you want to accomplish
    – Miguel
    Sep 12, 2014 at 20:59

2 Answers 2

1

You cant use C# on the CME as it is a Browser GUI

However you can use JavaScript and Anguilla framework to get the Webdav URL. It's not a very user friendly process, but anyway the Webdav URL is not meant to be used by editors anyway.

To accomplish this use the Browser debugger console or Firebug console and execute the following commands. Make Sure your are inside the Dashboard.aspx (specially after SDL Tridion 2013) and execute the following commands

myTemplate = $tcm.getItem("YOUR_TEMPLATE_URI")
myTemplate.loadWebDavUrl()
myTemplate.getWebDavUrl()

This will be the results on your debug console:

Console

0

The only place you can use C# within the CME is in a C# based Template Building Block (TBB)?

If that is what you are trying todo, you could use a snippet like (taken from C# TBB assembly):

// get a reference to the page
Page page = null;            
Item pageItem = package.GetByType(ContentType.Page);
if (pageItem != null)
{
   page = (Page)engine.GetObject(pageItem.GetAsSource().GetValue("ID")); 
}

if(page != null)
{
   // Loop Component Presentations
   foreach (ComponentPresentation cp in page.ComponentPresentations)
   {
      var componentTemplateWebDavUrl = cp.ComponentTemplate.WebDavUrl;
   }
}
2
  • engine.GetObject(pageItem.GetAsSource().GetValue("ID")) :) :): ) Sep 14, 2014 at 6:54
  • What about Events? Sep 14, 2014 at 19:15

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.