Using different templates for several instances of a single ContentType

Topics: Customizing Orchard
Jun 16, 2011 at 1:51 PM

Hello everyone,

I am currently facing a problem concerning the way to display content items, and I need some help. Let me explain :

I made the choice of using a single ContentType to manage about everything on my Orchard website (news, static pages such as "about" page, "customers" page etc...). Let's call this ContentType MyType.

I created several lists that contain items of the MyType ContentType.

Although all my items are of the same type, I would like to display some items differently. For example, my news list should not look like any other list on my website, although they contain objects of the same type (so the Summary view should be different I guess).

I saw it is possible to use Alternates (http://orchardproject.net/docs/Alternates.ashx) to use different templates, by matching conditions defined in the placement.info file (http://orchardproject.net/docs/Understanding-placement-info.ashx#Match_Element_3).

However, I am not satisfied with the 3 possible ways to match items, because :

  • I cannot filter by ContentType (they all have the same ContentType, MyType)
  • I cannot filter by DisplayType (I potentially want to customize 2 alternates for the Detailed view)
  • I prefer not to filter by Path : I'd like to enter any URL for an item without wondering which rule is gonna be matched.

So my question is, has anyone faced this kind of problem ? Is there another way to customize the way items are displayed ? Maybe I'm doing things in a totally wrong way ?

Thanks in advance !

Jun 16, 2011 at 4:27 PM

I'm wondering why you've decided to represent everything with the same content type. The whole point of being able to create different content types is to get around exactly the problems you're describing. Maybe you just need to approach it that way?

Coordinator
Jun 16, 2011 at 7:33 PM

+1: you painted yourself into a corner there.

Jun 17, 2011 at 8:28 AM

I agree the original idea of using a single ContentType was a mistake.

The point was actually to make it very simple, so that the contributor would not have to think about which ContentType he's gonna use.

Well, following your advice I eventually made several ContentTypes, so my rendering problem is no more !

Thanks !