One item (contentitem), multiple views?

Topics: Developer Forum
Apr 16, 2009 at 9:23 PM
Is it possible to have one item (the class in the items folder), but have multiple views?

For example, if I've extended the NewsItem with an image and some other properties, and I wan't to reuse this but present it in several different ways with different markup, how can I do this?

// Johan
Coordinator
Apr 16, 2009 at 11:04 PM
One way is to use the path after the item.

E.g. if the items url is

/path/to/my/page

then you can make use of the remaining url to access another template

[Template("details", "~/detailsview.aspx")]
public class NewsItem : ContentItem

The path to this template would be
/path/to/my/page/details

If you need this to be more dynamic you can either override FindPath or use an adapter concept, but that's slightly more tricky.