This is probably basic but...

Topics: Customizing Orchard
Aug 12, 2011 at 4:17 AM
Edited Aug 12, 2011 at 4:18 AM

I am not new to MVC or webdesign\development in general but some of the stuff in Orchard is throwing me for a loop. I love creating content with pluggable parts but I need some help on something that I would think is pretty simple.

So I created a new content type called "Profile" and a list content type called Profiles. I added the Container Widget on my home page and get the usual list view.  I want to customize the way the items are rendered in the list but the problem I have is that I can't tell how I am supposed to render the more complex items.

Mainly, I can see a

@Display(Model.Content)

doing all of the heavy lifting. I know I can specify certain parts like

@Model.ContentItem.BodyPart.Text or 
@Model.Title
But things like tags or even ImageField? I just don't know how to reference them in my alternate view. Any help would be greatly appreciated. I really want to take off with Orchard but feel it is a little slow going.


Coordinator
Aug 23, 2011 at 1:46 AM

If you have a text field called Foo on a Bar part for example, it would look like @Model.ContentItem.Bar.Foo.Value.

Aug 25, 2011 at 1:46 PM

you would be better off creating a custom module in code and then defining your templates for that, when you write the custom module In your driver class when you create the shape if you pass in the part as in the example below you can access all your fields from

all your content parts easily, even if you multiple content parts that contain Image fields or Html fields you can access all the data through the model easily.

Example Driver Class:

protected override DriverResult Display(PromoBoxPart part, string displayType, dynamic shapeHelper)
        {
            return ContentShape("Parts_PromoBox",
                () => shapeHelper.Parts_PromoBox(ContentPart: part));
        } 

By doing this you can then access all the contentparts attached to the widget through the model:

example:

You have a Custom Content Type that is made up of multiple ContentParts and one of your ContentParts has a field called Image which is a MediaPickerField (downloadable from the gallery) you can access the data in the model like this:

@Model.ContentPart.ContentItem.MediaImagePicker.Image.Url