2

I am trying to create a layer rule in the widgets section that shows a widget on all pages except two (or more). I've tried a number of options, in some cases the rule will exclude one page but not the other, in other cases it does not exclude either.

At first I wasn't sure how the exclude would work, I tried true not url("/page-1") which returned the error "The rule is not valid: Syntax error: Unexpected token in primary expression (Token 'Not' at position 5)", so I switched to not url("/page-1") which works (for excluding just one page).

I tried a number of ways to exclude more than one page without any luck, including these:

not url("/page-1") or not url("/page-2") // not excluded on any pages
not url("/page-1") or (not url("/page-2")) // not excluded on any pages
not url("/page-1") or url("/page-2") // excluded on page-1 only

I found this issue which confirmed that url("/foo") or url("/bar") is how you include two URLs, which would suggest that the first example above is at least close.

Is it possible to show a widget on all pages, with a few specific pages excluded? Also, either way, is there a different method recommended for doing something like this, other than using a widget layer rule?

wentz
  • 700
  • 5
  • 15
  • I wanted to do something very similar and ended up writing a condition so that I could include/exclude pages from a layer based on a tag, i.e. have a layer rule of `tag("name of tag")`. I've uploaded the module to the modules gallery (https://gallery.orchardproject.net/Packages/RW.Orchard.Conditions) should it be of use to you =) and blogged about how I put it together as well (http://robertwray.co.uk/blog/writing-a-custom-condition-for-orchard-checking-the-tags-on-a-page-published-to-github-and-the-orchard-gallery) – Rob Aug 24 '17 at 14:44

1 Answers1

2

This works:

not (url("/page-1") or url("/page-2"))

I'm chalking this one up to being a little out of practice with logical expressions.

wentz
  • 700
  • 5
  • 15