2
votes

I'm trying to reproduce this layout in Orchard. So far, I've got most of the stuff worked out by using an alternate for my blog post detail (Content-BlogPost.Detail.cshtml). The problem is that the layout I've created looks something like this:

enter image description here

My first question is, does this layout make any sense? Is there a better way to accomplish this result (that is, getting the archives displayed in line with the content)?

Secondly, is there a way to render a zone (or a widget) from inside my alternate? I tried doing @Display(Model.Archives), where Archives is the name of my zone, but obviously the blog detail model doesn't define an Archives property. I also considered manually calling out to the Blog Archives shape with something like

@Display(New.Parts_Blogs_BlogArchives(new { Blog: blog, Archives: ???})

But I don't know how to populate that second argument.

What's the right way to make this layout happen in Orchard?

1

1 Answers

7
votes

The main problem with this layout is that the Archives zone is being placed inside the markup for the blog post. That makes things harder to render, but not impossible.

The solution would be to render the whole layout zone inside your alternate, exactly like you said. You can display the main, top-level layout zones from every shape like this: @Display(Layout.Archives). Layout is a property that gives you access to the main Layout shape.

I'd do it like this:

  1. Add a zone called Archives in your Theme.txt manifest file (Zones section) that will be a placeholder for blog archives widget. Make sure you would not render it in Layout.cshtml file. This zone will be strictly for blog post purposes (you can also give it a different name to note this).
  2. Create a shape alternate for blog post, like you did, and call Display(Layout.Archives) in appropriate place. This will render the whole zone inside the blog post markup.
  3. Put the blog archives widget in the Archives zone.

Now, every time any blog post gets rendered, it would also render the archives widget.