3

In the Tridion CME, an admin can check a box on a Page to make it a Page Type. How do we do this programmatically via TOM.NET (or some other means)?

I've been looking through the TOM.NET API and can't find the answer here. The Page class doesn't seem to have a property nor a method for this.

3

XMP (SiteEdit) information is stored in CMS as application data, so you can do this using TOM.NET API by simply using the SaveApplicationData method of Page object. The only part that needs to be known is the format of the App Data to be used to create for XPM. There is not much documentation on this topic on what the format of the data looks like.

AppData XML structure is key and format has to be the same.

Here is the code using TOM.NET API

Page pg = ....// Get the page object using TOM.NET

string xpmXMLStr = @"<configuration xmlns=""http://www.sdltridion.com/2011/SiteEdit"">
                     <Page xmlns=""http://www.sdltridion.com/2011/SiteEdit"">
                       <PageType>
                            <Enabled>true</Enabled>
                            <Description>sa</Description>
                            <PreviewUrl>/abc</PreviewUrl>
                       </PageType>
                      </Page>
                     </configuration>";

ApplicationData appData = new ApplicationData("SiteEdit");
appData.TypeId = "XmlElement:configuration, http://www.sdltridion.com/2011/SiteEdit";
appData.Data = System.Text.Encoding.Default.GetBytes(xpmXMLStr);

// save the page application data (saving the XPM settings.)
pg.SaveApplicationData(appData);

The same can be done using Core Service API as well.

1
  • I would recommend against doing this. You will be overwriting the entire SiteEdit configuration, not just the Page Types. The XML that is stored is not a public API, so if you mess it up or if the format changes in the future -- you will get bugs that nobody will be able to reproduce (most likely). At the very least, you should be reading the existing data (if any) and adding the Page Types to it -- and also should be using the Data Adapter with the root element of the XML (=XmlElement type) instead of a string with the default encoding! Jun 13 '14 at 8:10
2

I suspect you can't do this with the TOM api as XPM is a GUI extension on top of the CMS.

It's probably possible to update the Page XML using the TOM API / Core service to added the relevant checkbox into the page content XML. I say 'probably possible', I suspect the checkbox is stored as <tcm:extensiondata> and i'm not 100% sure you can update this via the XML methods of the TOM.NET / Core service API, if you can, then great.

Update:

<tcm:extensiondata> is available on CMS items to allow your extensions to store additional information against a tridion item. it's really useful when creating GUI extensions as you can store information directly with the item and it's available to and from the item XML. Your extension can read this information and you can implement things into the CME interface, for example... If you wish to add a button to the Component dialog 'Show in navigation' you could check this box and have your GUI extension store this back into <tcm:extensiondata>

2
  • can you expand a little more on the <tcm:extensoindata> node and how that works to set some context to the answer? Jun 11 '14 at 16:30
  • 1
    added an update my man!
    – johnwinter
    Jun 11 '14 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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