Custom Layer Rule syntax

Topics: Troubleshooting
Aug 20, 2011 at 10:15 PM

Dear community members!
I need help with building custom Orchard CMS Layer Rules.

For example,
`!url '\start-uk-UA'` works for me,
but more general `!url '*-uk-UA'` does not.
Bertrand Le Roy [says][1]:
> You can in fact write much ore complex rules as the language that’s
> being used to parse the rules here is IronRuby.

But I can't find any useful info in IronRuby docs.


Aug 22, 2011 at 1:46 PM

@mrykov I know that you can do simple things like [and, or, not] for combining rules, but beyond that I'm not sure how much you can do in IronRuby itself.

What you can definitely do is write your own rule providers. So for example, the code that actually executes to determine if url('~/foo') evaluates to true or false. To do that just implement IRuleProvider. The url rule is a good example you can follow: Orchard.Widgets/RuleEngine/UrlRuleProvider.cs

Aug 22, 2011 at 6:30 PM

not url("*-uk-UA") should work, from the top of my head.

Aug 22, 2011 at 8:00 PM

Thanks for the answers!

@bertrandleroy no, the double quotes miracle didn't happen.

Maybe, it will be a really simplest to write my own IRuleProvider implementation.

Aug 22, 2011 at 9:15 PM

Single quotes vs. double quotes shouldn't matter inside the url method call. You shouldn't have quotes around the whole expression though. Also Bertrand might be saying to use the express not instead of !

Aug 31, 2011 at 10:50 AM

anyone that can help me with a code or something that will allow me to show widgets on different window tabs

i basicly have four window tabs and need the widgets not to show on one of the tabs

any help will be appreciated thx

Aug 31, 2011 at 7:53 PM

You mean browser tabs? I don't think that is possible.

Sep 1, 2011 at 9:41 AM
Edited Sep 1, 2011 at 9:43 AM

incase you mean different pages on your site.

create your widget, add it to a layer and for the rule add:


url ("~/page1") or url ("~/page2") or url ("~/page3")


I'm not quite sure what you try to accomplish with the example in your first post.

I assume you want to show it on any page except those ending on uk-UA.

that is not possible as far as i know with the standard layer rules.

however there is a module in the gallary allowing language layers. ( Culture Layer ), so install that and try


not Lang "uk-UA"


as a rule. should do the trick, if that's what you want to do.

Sep 15, 2011 at 8:57 PM

I'm looking for a little help on a rule I'm trying to implement.  I want a set of menu's to display only when on a specific section of the site. Basically, I want a different set of menu's to show up for /publication*.  I am able to get the publication menu to show up when in that part of the site with this rule:

authenticated and (url('~/publication-3319') or url('~/publication-3319/*'))

But I can't get the main menu to hide/not display when in the publication section.  I've tried the following rules:

authenticated and not (url('~/publication-3319') and not url('~/publication-3319/*'))

authenticated not (url('~/publication-3319') not url('~/publication-3319/*'))     ****** this will not let me save the rule.


Okay... as I was trying different things I got this to work:

authenticated and (!url('~/publication-3319') and !url('~/publication-3319/*'))


I'll post this just to post it.