Elegant way to separate Parts.Common.Body.Summary.cshtml for Recent Blog Post Widget vs Blog?

Topics: Customizing Orchard, Writing themes
Nov 3, 2012 at 7:03 PM
Edited Nov 3, 2012 at 7:03 PM

I'd like to use one cshtml razor file for the "Blog summary" but for "Recent Blog Post Widget" I'd like to use the default razor code.

Unfortunately the shape tracer doesn't immediately point out an alternate nor am I able to think of an elegant way to do this.  I'd prefer not to do it with a URL alternate or ID specific.



The cshtml in question is "Parts.Common.Body.Summary.cshtml"

Nov 3, 2012 at 7:11 PM

For the blog post summary have you tried defining an override with Parts.Common.Body.Summary-BlogPost.cshtml ?


Nov 3, 2012 at 8:31 PM
Edited Nov 3, 2012 at 8:43 PM

Thanks for the quick reply and suggestion.

Unfortunately both the blog and the "recent blog post widget" leverage Parts.Common.Body.Summary-BlogPost.cshtml just as they both leverage Parts.Common.Body.Summary.cshtml

That is, both offer it as an alternate and if I rename the cshtml to that it is still picked up by both.

Is there a way to have the cshtml choose itself based on the widget type?  Something like: Parts.Common.Body.Summary-RecentBlogPostWidget.cshtml where it picks up this cshtml if it's a Body.Summary *and* finds itself in the RecentBlogPostWidget widget?

For now, I enabled url alternates and used Parts.Common.Body.Summary-url-blog.cshtml but would be interested in seeing how others did this.

Nov 5, 2012 at 8:22 AM

Did you enable widget alternates?

Nov 26, 2012 at 7:23 PM

I'm trying to do the same thing but haven't got very far. I have enabled widget alternates but I haven't been able to get a different template loaded. Shape Tracer only seems to suggest URL alternates.

Dec 11, 2012 at 9:46 PM

I have a problem like this, i have two projection-widgets in homepage, and want different templates for Parts.Common.Body.Summary in each projection. But the shape tracer don't suggests any alternate. Can anybody help me?


Dec 11, 2012 at 10:15 PM

In the projection layout, you can specify a different display type. That can be used to switch to a different template.