This project is read-only.

Template for content type

Dec 9, 2010 at 12:57 PM

Is there any facility to provide custom template for content type listing? For example, I am creating an event content type with several fields. By default, it gets displayed with a series of p and span tags. Is there anyway to customize how a content type gets rendered from the admin UI? 

Dec 9, 2010 at 10:42 PM
Edited Dec 9, 2010 at 10:43 PM

As far as I remember customization (overriding) of content type default display is done by themes. Modules define shapes that themes override.

So you should write your own theme (eg. based on some existing theme) and override your content shape by putting an appropriate .cshtml file under /Views folder tree (as stated in docs, eg. Content-<ContentType>.<DisplayType>.cshtml.

Or, of course you can create the .cshtml file and just place it in the current theme's /Views folder, without creating your own theme.


Jan 19, 2011 at 9:13 PM

I can not get this to work. I Have added a Content Type called "Sport".

Next I Added a list to which i also added a content item of the type "Sport"

So, i now have a page displaying a list of sports, currently just one sport. And that is displayed with the default theme look.

I would like to add a template for JUST THIS PAGE to display the items in a specific way.. Is that possible?

Jan 19, 2011 at 9:57 PM

Did you try this technique: ?

Jan 20, 2011 at 11:07 AM

Actually that didn't make anything more clear :)

For starter, how do i add a displaytemplate (or cshtml file whereever it might be placed) that displays a specific contenttype based on my code? What is the naming of the file? I cannot find any information that works....

Jan 20, 2011 at 7:42 PM

If you want to modify how the sport content type appears in lists, you need to create a file named Content-Sport.Summary.cshtml in the Views directory of your theme. Now if you want to differentiate how this looks on different pages (but it's not clear that's what you're trying to do) then you need to do something like what I'm doing in my post because you're going just a little beyond what's in the box.

Does this clarify a bit?

Jan 23, 2011 at 6:34 PM

So, that filename gives me the option to manually write my own presentationcode for a contenttype. Thank you very much. Now to the next question. Lets say that i want to do just this, manually handle my presentationcode for a specific contenttype, BUT i also want to do this PER page.

I implemented the filter according to the link but the problem i have is that i have a page that is displaying a list so the BuildShapeName is returning "Layout__Containers__Item__Display". It has nothing to do with the current page i am on. I still want it to maintain the layer and all that, just how do i modify how THAT list content is displayed?

Jan 24, 2011 at 7:34 PM

This technique of adding alternates can apply to any shape. That container shape can be added alternates depending on the current page.