Control projection html in custom theme

Topics: Customizing Orchard, Writing themes
Apr 27, 2013 at 8:02 AM
How can I control the html of a projection I created on the backoffice?

I created a custom theme and created a Content-url-mycustompageurl.cshtml but I can't figure out how can I iterate on the results of the projection because I only have a Model that is dynamic and I can't figure out what properties to access...
Apr 27, 2013 at 2:56 PM
When you create a projection you select what display to use on it. I think it defaults as Summary. To control how items get rendered you would create an alternate for the content item and the display type you are using.
To control how the projections html is rendered, i.e. the list element that wraps each content item in the projection, you can create an alternate for that too.
Apr 27, 2013 at 3:58 PM
Thanks for the fast reply Hazza.

I created an alternate for the url that uses the projection, but I can't figure out what properties to use on the Model to iterate on the projection items...

The Model is dynamic and I didn't had any success inspecting it on debug. Do you know why property on the Model should I access?

How can I define an alternate for the projection? Lets say my projection is named "TopCars", can I use Content-TopCars or Content-Projection-TopCars?
Apr 27, 2013 at 4:08 PM
Without knowing what properties you are trying to access I cant really help you.

I would advise you to download the Designer Tools module from the gallery and enable Shape Tracing. This gives you a tool that lets you inspect shapes and automatically create alternates. It can also let you see the properties of the dynamic model.

It can be found here:
Apr 27, 2013 at 9:12 PM
That was the first thing I tried, but I didn't find it useful.

For some reason when I expanded the shape tracing frame it shown the page tree but on the "shape", "model", "template", etc tabs were empty, at most there was a file name on the blue bar before the content.

I will take another look at this on monday morning to see if I can find out something more...
Apr 29, 2013 at 1:20 AM
hi, rjmlopes
you can try video :
Apr 30, 2013 at 7:30 AM
I've done something similar, but had no problem finding the items within the shape tracer. The projection created the initial widget shape then used a shape for the content returned. I have a Director content type with Title content part and custom field of Role. My alternate summary template worked out as


so I assume yours could be Content-TopCars.Summary.cshtml

The model worked out pretty funky. @Model.ContentItem.TitlePart.Title and @Model.ContentItem.Director.Role.Value to display the values of the content item.

Summary template was called by each shape returned from the projection via
    var buildShapes = Model.BuildShapes;    

@foreach (dynamic shape in buildShapes())