Layout alternate wildcard?

Topics: Customizing Orchard
Nov 18, 2013 at 1:48 PM
I want to create a layout alternate for a certain group of pages, specifically /news/*. Can url alternates use wildcards? If not, what other solutions can I consider?

Thank you.
Nov 18, 2013 at 3:30 PM
Alternates managed from can handle wildcards in the Match element.
Nov 19, 2013 at 12:13 AM
Hi Piedone,

I actually tried that but struggled constructing the Place element. If my content type is Blog Post, then my Place element would be something like:
<Match Path="~/news/*">
    <Place Part_BlogPost="-"/>
The "-" is just to test if the override works, but it's not working. How should I construct the Place element?

Nov 19, 2013 at 12:55 AM
BlogPost part actually doesn't render anything. You might want to test with something else, like title part of body part.

Nov 19, 2013 at 1:15 AM
A content type can have an alternate view, right? Like Content-BlogPost.cshtml in this case.

However, my goal really is to use multiple Layout alternates based on url wildcards. How can I do that using

Thank you.
Nov 19, 2013 at 1:45 AM works for shapes created by drivers of parts and fields (I don't know how it works for fields), So, in your case, with content and Layout, it's irrelevant I think. And URL alternates seem to work only with single URL, so no wildcards.

What might work for you is to create a IShapeTableProvider as described at the end of, provide an alternate for Layout, when the request URL contains /news/. You might want to use Shape Tracing tool to find out if that worked and an alternate is provided when you browse a page under /news, and create a view for that alternate in your theme. You can use the same provider to add different Layout alternates for diffenent conditions to meet your goal of multiple alternates.

Disclaimer: I haven't tried this, and I'm not sure if Shape Tracing works at Layout level. I would be glad if you post back and let me know if that works, in case you want to give it a try.

Good luck.

Nov 19, 2013 at 9:13 AM
Ah, I missed that it would be an alternate for Layout. BTW Path works without a leading tilde, see:
Nov 22, 2013 at 9:23 PM
Now it tried and URL Alternates actually works with "wildcards": e.g. Layout-url-news will be active on /news but also on /news/else.