This project is read-only.

Custom Layout for Custom Content Item

Topics: Customizing Orchard
Apr 9, 2012 at 8:54 PM
Edited Apr 9, 2012 at 9:22 PM

So, using Shape Tracing, I can create a view for a custom content item. However, when I view that template, it doesn't include any of the custom fields I have as separately bound items. The template I see is this:

@using Orchard.Utility.Extensions;
    if (Model.Title != null) {
        Layout.Title = Model.Title;
    var contentTypeClassName = ((string)Model.ContentItem.ContentType).HtmlClassify();
<article class="content-item @contentTypeClassName">
        @if (Model.Meta != null) {
        <div class="metadata">
    @if(Model.Footer != null) {

However, I was expecting something more like this:


What would my custom fields be called if I wanted to rearrange the template?

Apr 9, 2012 at 10:05 PM

That's the Content shape template you're overriding. Templates are just code files on disk - they're not dynamically generated. So the Content template doesn't know about the parts and fields you've added to your content type. How could it?

Instead, what it does is declare several local zones (really, just another kind of shape). Those are the @Display(Model.Whatever) lines that you see. So you have the following local zones available in that template: Header, Meta, Content, Footer.

Now, the shapes that are generated by the parts and fields on your content item are placed into those zones by a file. <shamelessPlug>BTW, I cover all of this in my Pluralsight courses on Orchard</shamelessPlug>

So anyway, if you want to move things around just specify where you want shapes to go in your theme's file. You can even use that Content template you have there to provide different local zones if you want.

Apr 9, 2012 at 10:17 PM
Edited Apr 9, 2012 at 10:19 PM

When your content item is being rendered using this template, all of the drivers will have been invoked and the shapes will have been created and added to the local zones of the content item (local zones in this case being Header, Meta, Content and Footer).

So, if one of the drivers created a shape called Parts_Common_Body which was placed in the Content zone, I assume you should be able to access and render it like this: @Display(Model.Content.Parts_Common_Body).

I haven't tried that though, so not sure if it works that way. What I did try before successfully is rearranging using just the local zone names, introducing new local zones as needed.

For example, let's say you wanted to rearrange the template so that a shape called TwitterHandle was rendered below the footer into a local zone called TwitterZone. That would be a 2-step process:

1. Update to place a shape called TwitterHandle into a zone called TwitterZone.
2. Update the template to include a call to @Display(Model.TwitterZone).

Apr 9, 2012 at 10:20 PM

Thanks. I just got it but didn't get a chance to respond yet.

I also found that if I wanted to I could just update the view down to the item level such as: Model.ContentItem.Employee.TwitterHandle.TwitterIcon and Model.ContentItem.Employee.TwitterHandle.TwitterName if I'd like.

Sep 6, 2012 at 1:12 PM


I know this is an old thread but maybe you can help me out here. Kinda stuck. 

Placementinfo is fine if you want to render shapes in a particular order and zone. But let's say I'm display searchresult summaries. A call to @Display will render all the shapes using their respective templates. Howeverm what if I need more control, let's say add two of the shapes in a containing div?

Writing a template that does this using: @Display(Model.Content.Parts_Common_Body) instead of displaying the contentitem would be perfect for this? Can't get it to work though. Are these individual shapes available?

thanks in advance,


Sep 12, 2012 at 7:44 PM

You may want to read this:

May 2, 2013 at 3:52 PM
Edited May 2, 2013 at 4:01 PM
Hi, I am a bit stuck on this very thing. I have been watching kevink's tutorial, in particular, shapes and how to modify the placement file.

I have created a content type called 'Property' (in a container called 'Properties') which displays various custom fields such as Name, Location, Price etc. In my placement file I have added some code such as:-

<Match DisplayType="Summary">
   <Place Fields_Enumeration-property-type="Content:1"/>
    <Place Fields_Common_Text-Name="Content:2"/>
    <Place Fields_Common_Text-Price="Content:3"/>
I want to try and change the order of these text fields on the summary page. I am going about this the righ way? It is not working!

I would be v grateful for any advice!

Tx, Kirsty
May 2, 2013 at 3:55 PM
What issues are you experiencing?
May 2, 2013 at 5:55 PM
Edited May 4, 2013 at 6:41 PM
The 'property-type' name looks suspicious to me. What are some of the alternate shapes the tracing tool offers for this item?