Manually iterating over items such as menuitems and blog posts

Topics: Core, Writing themes
Dec 15, 2013 at 10:21 AM
Orchard always added a <ul> <li> for list-based things such as menu items or blog posts that cannot be removed even when I manually override Parts.MenuWidget-MyZoneName.cshtml or MenuItemLink.cshtml. This is giving me problem as I am porting an existing template which uses a lot of DOM manipulation and jQuery plugins that relies on the markup not being altered in any way by Orchard.

I've been programming for 5 years but this is my first time working with Orchard, ASP.NET MVC or Razor syntax.

My feelings tell me that I should override the whole behavior and iterate over the list myself. Can anyone show me how to do that?

I'm thinking of something like
var items = getAllPostInBlog("nameOfMyBlog");
for each (item in items) {
    print "<div class=list>";
    print item;
    print "</div>";
}
Thanks!
Dec 15, 2013 at 11:47 AM
You can try overriding Menu.cshtml and MenuItem.cshtml. The originals are in \Orchard.Web\Core\Shapes\Views folder. You might get it work for menus. Shape Tracing tool helps to override the templates in your theme.

For blog posts, is this a projection, or blog archives/recent posts you are rendering? For projections you can use Shape layout, and go from there. For other kind of lists, take a look at http://weblogs.asp.net/bleroy/archive/2011/03/27/taking-over-list-rendering-in-orchard.aspx

Good luck!