Where to Drop a Custom Driver in a Theme?

Topics: Customizing Orchard, Writing modules
Jun 8, 2013 at 11:58 AM

I spent a good part of the last couple of days getting slightly better at building and rendering content types & parts. I created one of the page types for a new site using content-parts, content-types, projections and the right templet. Things were elegant. The projection templet was down to a loop and a Display(productFeature) call.

But of course things didn't remain so simple and elegant. The requirement is that on odd rows display an image on the right; on even rows, display on the left. Sigh.

So, to keep things as I want them (simple, clean, neat), I need a Display(productFeature, left) and a Display(productFeature, right), along with the corresponding templets of course.

There are lot's of 'blogs and articles on shape rendering, templets and writing custom modules, but I can't find the answer to the question:

Can I write a custom Display() function in my theme? If so, where do I put it?
Jun 8, 2013 at 6:57 PM
Edited Jun 8, 2013 at 6:58 PM
You could, but I don't understand why you need it. Display is used to render shapes. Put a property on that shape before rendering it. Then from within the view template of that shape, access that property to determine where to render the image. E.g.
myShape.ImageLocation = "Left";
Then, from the shape template:
var imageLocation = Model.ImageLocation;

if(imageLocation == "Left"){
   <div class="align left"><img /></div>
else {
   <div class="align right"><img /></div>
Jun 9, 2013 at 6:07 AM
Ah, that's a nicer solution, thanks. I tried something like that initially, but didn't realise that I could attached directly to the model. Trying to set an enumeration field from the projection didn't work.