This project is read-only.

Combined shape markup toooo complex?

Topics: Customizing Orchard, Writing modules, Writing themes
Jul 11, 2011 at 11:18 PM

Hi Pete  very appreciate your Mechanics

But need some enlightenment where am I wrong

consider the following deliberately simplified  (it could be more complex) snippet what I am successfully use


    var contentItem = ((IContent)Model.ContentItem).As<ContentPart>().ContentItem;
    var part = contentItem.Parts.Where(a => a.PartDefinition.Name == "Gallery").FirstOrDefault();

    var item = new {
        Title = Extensions.RouteTitle(Model.ContentItem),
        Image = part.Fields.First(a => a.Name == "Image").Storage.Get<string>(null),

      <div>  @Html.Image(item.Image, "", null)</div>
       @Html.ItemDisplayLink((String)item.Title, contentItem)

You see if instead I use @Display(Model) I get too extra markup from a great lot of nested shape/zone markup (for example in case I use  Downplay.Mechanics Paperclip) 

But in many cases I need clean and sensible markup so I simply dig out (sometimes it could be very deep)
the needed data from the Model and do whatever I like with it.

This way I feel much more flexible to implement the view i like
than if try using the (never succeeded fully and too boring)

So the question is what is wrong with such way?

Thank you