This project is read-only.

How powerful are Custom Content Types?

Topics: Customizing Orchard, General, Writing modules
Jul 1, 2013 at 2:36 PM
As a new Orchard user I'm wondering about a scenario I'm having. I want to display horses on my website in a standardized manner.

I'm talking about using Queries and layouts and projecting them based on taxonomies and all that, pretty standard Orchard stuff I suppose.

The Horse part will be pretty simple, A name, picture, description and perhaps a rating in addition that it can be perhaps tagged and sectioned by taxonomy.

Would a Custom Content Type be powerful enough to handle all that or would I have to design ( or use and already existing ) my own module for this.

Content Types seems pretty nice and you can alter it's appearance using the layout display mode thingy. But I'm seeing a few issues already. The custom fields I can add are somewhat limited. Numeric field seems to be integer only when my rating item needs to be decimal and so on.

Is this what Content Type was designed for or should I start learning how to do my own Module?
Jul 1, 2013 at 2:50 PM
Quite powerful I'd say.
This is what Content Type was designed for: to define your own data structures using reusable parts and fields. In your case, you could create a Horse content type with a couple of parts & fields.
When the out-of-the-box fields or parts don't suffice (e.g. a Rating type of field or part) you should search the Gallery if something exists to suit your needs. If not, create a module that provides the part or field that you need. For Rating, you could have a look at Contrib.Voting. It exposes a part which you could attach to your content type.
Jul 1, 2013 at 3:10 PM
The NumericField can handle decimal.

Just edit the settings of the field (extend the Field in the edition page of the Content Type) and set the Scale property.
This is the number of digits displayed the right of the decimal.
Jul 1, 2013 at 3:14 PM
This is great to know, I was hoping it would work like this. I just wasn't aware fields could be added from the gallery like Parts, Types and Modules.

Let me ask two more questions then about my scenario:

1) I can manage the look and feel of my query/projection using the Layout Display mode but the actual Content-Item-Page also needs some work on it. I understand the Theme specific changes I could make using Horse.cshtml view. But there are also some other things I would like to render differently on my Custom Content Type. The fields for example appear there with their name in front as label. What would be the best way change the rendering of custom content types on their permalink page.

2) Creation/published date I always assumed was a ContentPart that I could remove but it doesn't appear to be that way. I guess it's an integral variable in Orchard Content then, so I guess not displaying it would be something related to question 1.
Jul 1, 2013 at 3:48 PM
Edited Jul 1, 2013 at 3:49 PM
  1. The best way depends on your exact theming requirements. One way is to completely take over rendering and do everything from your Content-Horse.cshtml view (from which you access parts and fields directly). Another way is to render a couple of zones here and there, and use to designate individual shapes to their correct zones. For each part and field shape, you can create a view to customize its rendering. E.g. if you want to not render the name of textfields in front of its value, you could create a view for that field specific to your content type using an alternate: Fields.Common.Text-Horse.cshtml. You can even create alternate views for individual (named) content fields. And there are many more alternates that can be used, and easy to create alternates yourself.
  2. Creation / Published are properties of the CommonPart. You can choose to not render its shape using
Jul 1, 2013 at 3:59 PM
Ok, I'll have to look into shapes a bit more, so much to read in so little time.

But the common practice seems to be that Themes should control rendering. I guess that makes sense in a way.
Jul 1, 2013 at 4:08 PM
Yes. Modules provide default views for their shapes, but it's up to the theme to fully customize rendering if necessary. Could not be more beautiful.