5

Using Tridion 2011 with VBScript templating, I'd like to know the best approach for creating a grouped presentation / group relationship? For example:

There is a GenericContent component containing a heading, paragraph, and three image sizes.

There are four Component Templates:

  1. Content with thumbnail image
  2. Content with portrait image
  3. Content with landscape image
  4. Content with no image

These can be used as standalone component presentations. How would four of these GenericContent components, each using a different component template, be grouped to create a carousel type interface?

The carousel (group relationship) may also need information stored against it, such as an overall heading for the group e.g. "Featured articles".

2

For an Experience-Manager and author-friendly approach consider page regions or page template logic to create the grouping. Authors would add these component presentations to a page and their schema and template combinations determined where they're placed.

Otherwise a typical approach is to use a container component that links to one or more componens along with an option for a template for each. Component template logic for this container would handle rendering each "embedded" CP. I've found authors struggle with this approach for a bit, but it works with training and good examples.

Update: "How would you select a component template from the container component?"

An embedded schema would give you two fields:

  • Component Link, allowing for the GenericContent schema
  • "Template selection"

Consider using Bart's Item Selector as a way to actually select the template.

The container's template would need to parse these selections or change the component and template selection into a component presentation. It'd be easier to use a Modular Component template, but any templating approach would work.

Also see Miguel's Content Injection discussion for variations, pros, and cons on the same idea.

5
  • Page regions aren't something we currently use, I'll need to take a look at them. We do use container components for other purposes and had considered them for this problem. The only issue is how would you select a component template from the container component? And would the template selection be based on the nested component's schema?
    – Stephen S
    Feb 1 '14 at 17:12
  • An embedded schema would give you two fields -- one for the component link and another for the "template selection." See Miguel's Content Injection discussion for variations on the same idea. Bart's Item Selector could be one way to actually select the template. The container's template would need to parse these, I'll explain more in the answer.
    – Alvin Reyes
    Feb 2 '14 at 21:01
  • Thanks all for the response to this. It seems there is no "best practice" for handling this type of scenario. Alvin, thanks for providing some implementation detail. Unless I have missed something, even with Bart’s Item Selector, there would be an issue with limiting the component template selection based on schema?
    – Stephen S
    Feb 4 '14 at 11:21
  • Item Selector lets you limit the type (component template in this case) and starting location, but to restrict the selection to just certain values, you could use a Category of keywords or your own validation (when selected, on save, or when publishing). In terms of best practice, I agree--there are two general approaches to choose a best fit from (page regions or content injection). Given a choice, I'd opt for regions. I'm next looking to try Nuno (and Angel's?) configurable region approach.
    – Alvin Reyes
    Feb 5 '14 at 13:15
  • Oh and in this case, "regions" don't need to be Experience Manager regions. You just need page template logic that groups the related component presentations.
    – Alvin Reyes
    Feb 5 '14 at 13:17
2

Alvin is correct that page template logic is key to providing the 'rules' needed to group these components based on logic. The components most likely have the schema as their common grouping type, so if the page template contains logic to determinine the group based on their schema (typically a tbb to group them in to the package), presentation code can be used to output a particular style of grouping based on a content type schema.

If a more flexible grouping type is needed template metadata can also be considered

2

In general, you can group the components together either by placing them in the page as components, or by making a carousel component consisting of component links. Your problem appears to be that rather than grouping components you wish to group component presentations... allowing for different renderings to be displayed in your carousel.

Tridion doesn't provide a "component template link", but in practice, the choice you need to offer the content editor is which rendering they wish to use. For this, and embedded schema allowing you to group together a component link and a text field is sufficient. The text field should be constrained to a list of values, and presented as a dropdown or radio. Once you know which rendering is wanted, your template can take care of this.

In compound templating this is a bit easier, because you can invoke a component template from within a component template. In VBScript, you might find that you need to do the logic for all your renderings in the same template, with the logic driven by what is selected for the text field.

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.