This project is read-only.

Overriding list rendering (not the summary items)

Topics: Writing themes
Aug 19, 2011 at 12:21 PM


In a new Orchard site (Yup i'm a noob, it's my first one) I have a custom "product" content type.

On a page with a list of these types, I already changed the summary of the items, and it looks nice. But now I want to have a sub-navigation listing all the products in the list. (the subnavigation to be positioned in the same Zone as the list itsself, not in the menu or so)

What is the best way to achieve that? I thought about overriding the list rendering itsself, and add a foreach loop over the list items, but I can't seem to find out how to override the list itsself)

Thanks in advance!

Aug 22, 2011 at 3:31 PM

Did some further research on this topic and I found this:

But I cannot seem to get it to work. For example; I tried the following as a test but is does not render my own template: "Parts.Products.Product.List.cshtml" (products is the list to which different "product" content items are added)

Would really appreciate some help here :s

Aug 22, 2011 at 7:26 PM

Did you try to use shape tracing in order to determine whether that is really the name you should be using for your template?

Aug 22, 2011 at 7:49 PM

Thanks for your response.

I tried, yes.

But I did not find a suitable name to override lists. I only found out about the alternate in this screenshot: (Tried to use this one, but it changes the admin lists as well...)

What am I missing?

Aug 22, 2011 at 7:52 PM

The driver for your products part will have to either produce a different shape than List, or set a display type that you can use to differentiate the template.

Aug 22, 2011 at 7:56 PM

hmm okay I understand, but the Products part isn't generated in code by me. Both the "product" and the list "products" are built in the admin with some parts and fields. 

Or is it possible to somehow override the driver's code responsible for the shape generation?

Aug 22, 2011 at 7:58 PM

In that case you could build a handler that creates an alternate for the shape, but for that to work, you will need to find a way to differentiate a list of products from a regular list. Can you do that?

Aug 22, 2011 at 8:03 PM

I guess I can use the "ContentType" in one way or another in the handler. If that's what you mean, I can give it a try :)

Thanks for the info so far!

Aug 22, 2011 at 8:05 PM

One extra question. If i'm not mistaken, I can put the handler right in my theme, yes? Just include it in the project file and the dependency injection system will take care of the rest, right?

Aug 22, 2011 at 8:08 PM

Yes, that's correct. The handler will then be active as long as the theme itself is.

Aug 23, 2011 at 8:26 AM

Hmm, from looking around I think I must override the BuildDisplayShape method in the contenthandler? Yes?

But my contenthandler never gets activated, so it seems.

  • I'm running inside VS 2010
  • The Handler resides in a folder "Code" in my theme
  • The theme has a csproj file and is added to the orchard source solution, for easy debugging
  • I set a breakpoint inside the handlers constructor

But the breakpoints are never hit... Am i forgetting something?


PS: this is the handlers code so far: (not much ;) )


public class ProductContentHandler : ContentHandler
		public ProductContentHandler()
		} <breakpoint here>
		protected override void BuildDisplayShape(BuildDisplayContext context)
		} <and breakpoint here>



Aug 23, 2011 at 8:01 PM

And... the csproj does point to your handler file, right?

Aug 24, 2011 at 8:34 AM

Aha no it doesn't. Shame on me :) Got the handler working, thanks for your help.

Besides this question; I was able to solve the original problem by creating a widget for the subnavigation... I then can include the widget on the page(s) that need it. Perhaps not the most elegant solution, but it works nonetheless :)