More on XPM Regions: Difference between Insert and Drag-and-drop

SDL Tridion's inline editing interface, or Experience Manager (XPM), lets authors update content in a way familiar to any post-Web 2.0 user: in context.

Rather than focusing on organizing content like the Content Manager Explorer, XPM lets you quickly set up pages and content in the context of your site.
Tangent: typical Web users and especially digital natives may take in context editing for granted, but consider the fact that this works even when applied to sites never designed to be editable. It could be a plain HTML site, powered by data feeds, or a typical .NET or Java setup. But I digress, today I want to explain a powerful, but likely overlooked XPM feature: regions.
Regions let us control what valid component presentations (schema and component template) and their quantities are allowed in certain parts of a Tridion-managed page.

Example from SDL Live Content (requires login):

<!-- language: lang-xhtml-->

    <!-- Start Region: {
      title: "My Region",
      allowedComponentTypes: [
        {
          schema: "tcm:2-26-8",
          template: "tcm:2-32-32"
        },
        {
          schema: "tcm:2-27-8",
          template: "tcm:2-32-32"
        }
      ],
      minOccurs: 1,
      maxOccurs: 5
    }
    -->

Authors interact with pages and regions in two was: drag and drop or with the Insert button.


Drag

Dragging a component lets you drop it into a region based on schema and min/max limits. If the region doesn't accept that type of content or it's "full," you can't place the existing content there.

Insert

But inserting a component from the library relies on an "unambiguous matching template." We can't automatically add a component to a page if a region has its schema paired with multiple templates.

This was so "obvious" to me that I've incorrectly assumed we can have at most one schema in the "allowedComponentType" pairs per region.

Indeed you can have multiple templates for a given schema in a region, the documentation clarifies:
The same schema value may occur multiple times in this region, combined with different template values; and the same template value may occur multiple times in this region, combined with different schema values. But a specific combination of schema and template values can occur only in one region.
So having multiple allowed Component Type pairs with the same schema and different templates actually works, with two benefits:
  • Dragging an existing component will choose the first match in the region
  • This also lets you control which CTs are available in Experience Manager's Layout tab.
But you do want a single schema-component template pair if we want an "Insert" to automatically choose the template for us. Otherwise you'll get an error choosing Insert (but not when dragging):

> You can not insert this component<br/> Selected component has no
> available component template

You'll get the same error if trying to add an item without any CTs for it, but in this case it should probably be something like: "dude, which CT should I choose?" I'll double check with product management if they'll consider this improved version in a future release. Be sure to vote for it on Tridion Ideas. ;-)

What's Better?

Regions are a decision to specify what content goes where for which pages in what quantities. Regions make authoring easier by paradoxically reducing choice. But when the choices are subtle, nuanced, or suggest restricting something the business might want to do later, the default assumption is "more is better."

Which sounds better? Twenty retirement plan options or just ten? More ice cream flavors or less?Restricting options sounds bad. Giving authors "ultimate flexibility" is the CMS battle cry! However, research, studies, and experiments show more options may sound attractive, but fewer will participate in the retirement plan.

Note: drag-and-drop will add the CP with the first matching Allowed Component Type for a given region. But without a region, you'll still get a corresponding CT but the selection isn't guaranteed. Peter Kjaer explains the details on StackOverflow and the fact that we can modify the data extender. In practice though, your earliest templates are often a good default choice as they tend to be the first designed and implemented.

From easy-for-implementation to easier-for-authoring:

  1. No regions gets you the Midas Rule: if you don't choose, the system will chose for your authors.
  2. Regions set up for dragging is good when you want to balance flexibility with some good defaults. Allow multiple templates and let authors add content then pick and choose templates.
  3. Insert, however, is faster and makes for an even easier authoring experience.
  4. Not mentioned here, but even faster and easier for authors is to actually make a variety of page types. These are as easy as making a "prototype" page and haveing a CMS admin check a box. With no additional schemas nor templates, you can create several pre-configured page options.

There should be a EULA to the installer that says, "If using Experience Manager, I promise to set up regions and page types for my authors."

More Background

The documentation explains **allowedComponentTypes** as:
An array of schema and template pairs. Your Page Template should only put Component Presentations in the region if they match one of these  pairs.
Your template logic (place matching CPs) is independent of the region syntax, though they should match per above. What this means to template developers is you should probably add regions in the same logic that you layout component presentations, regardless if that's in templating or delivery-side code.

Tip: don't hard-code regions except maybe to test them out and work out the syntax. Your basic scenarios would be:


Here's an example region with one schema matching different CTs. It should be obvious why you wouldn't want to handcraft these. :-)

    <!-- Start Region: {title:"Main", allowedComponentTypes:[{{schema:"tcm:69-6586-8", template:"tcm:69-6677-32"},{schema:"tcm:69-6586-8", template:"tcm:69-6592-32"}], minOccurs:0, maxOccurs:5} -->

Summary

In summary, if you have a region with a schema with multiple templates:
  • Clicking Insert will throw an error ("dude, where?")
  • Changing Layout will show both CTs as options to change to
Just one template for a given schema:
  • Clicking Insert will add the CP--you'll probably want to make sure you have no other "conflicting" regions
  • Drag-and-drop will add the CP with the matching template
But before using regions, your CMS implementation team has to make the decision to make the experience easier for visitors and authors.

No comments:

Post a Comment

Feel free to share your thoughts below.

Some HTML allowed including links such as: <a href="link">link text</a>.