Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I have flexible/catchall regions with Tridion XM/New UI/2012 UI

I am putting together a functional design for a site which will aims use the Tridion 2012 UI/XM to manage pages. There are 2 regions on the page, a main content area on the left and a side-bar on the right. Ideally users should be able to drag and drop content into and within these regions. In an ideal world I would like to define the regions along the lines of

  • Side Bar: any CP for which the CT has the text 'Right' in it.
  • Main: all other CPs

Looking at the documentation it seems that you need to explicitly use CT/Schema ID pairs to define regions. Is there any possibility to do this in any other way?

At the very least I would like to be able to define that the side bar allows a certain fixed set of CT/Schema ID pairs, but have the main region as a catchall bucket.. Is this possible?

It is also possible that the Side Bar is split into 2 regions, above and below an advertisement. Both regions should allow the same types of CP - as far as I understand this is not possible - is this correct? Are there any ideas for workarounds?

like image 330
Will Avatar asked Oct 16 '12 15:10

Will


1 Answers

To configure regions that take all Content Types, You need to get Publication AppData and loop through the content types and build your json markup for enabling this.You could write C# TBB which includes on each page template and does this logic, you can define some metadata at CT level which determines which region it will go in and build the Region JSON markup.

Below is the snippet to get all Component types to add in one region. You could change the logic to get only right just by checking the template name.

 // get the publication from the engine -- using TemplateBase Util..

    Publication thisPub = GetPublication();

    XmlElement seAppdata = thisPub.LoadApplicationData("SiteEdit").GetAs<XmlElement>();

    XmlNamespaceManager seNsMgr = new XmlNamespaceManager(new NameTable());
    seNsMgr.AddNamespace("se", "http://www.sdltridion.com/2011/SiteEdit");
    seNsMgr.AddNamespace("xlink", "http://www.w3.org/1999/xlink");

    XmlNodeList contentTypes = (XmlNodeList)seAppdata.SelectNodes("//se:ContentTypes/se:ContentType", seNsMgr); 

    List<String> contentTypeJson = new List<String>();
    foreach (XmlNode contentType in contentTypes)
    {
        string templateId = contentType.SelectSingleNode("se:ComponentTemplate/@xlink:href", seNsMgr).Value;
        string componentId = contentType.SelectSingleNode("se:Component/@xlink:href", seNsMgr).Value;

        Component thisSchema = (Component)engine.GetObject(componentId);
        string schemaId = thisSchema.Schema.Id;

        // Add json formated string for Content Types
        contentTypeJson.Add(string.Format("{{schema: \"{0}\", template: \"{1}\"}}", schemaId, templateId));
    }

    // Final Markup - JSON
     String allRegionSeText = string.Format("<!-- Start Region: {{title: \"All Region\",  allowedComponentTypes: [{0}],  minOccurs: 1,  maxOccurs: 5 }} -->", string.Join(",", contentTypeJson.ToArray()));

     // Push to the package to use in DWT..
     package.PushItem("ALL_REGION", package.CreateStringItem(ContentType.Text, allRegionSeText));

Hope this helps.

like image 119
Ram G Avatar answered Oct 13 '22 12:10

Ram G