This project is read-only.

Replace a widget in zone based on layer

Feb 11, 2011 at 4:07 PM


I have a html widget in the footer added to the default layer. I created a new layer to target anything after url "~/artwork" and I added a different widget to the footer with the same position number as the default layer widget. I would expect this to replace the existing widget when the non-default layer is matched but this is not the case, instead it gets added inline.

Is there any way to do this or will I have to code this behaviour into the theme?




Feb 11, 2011 at 7:16 PM

Layers are cumulative, so if you want something to not appear, you'll have to reverse your thinking: if a widget must not appear on certain urls, it should be in a layer that has a rule that is conditioned on the url not being "~/artwork". So add a layer with a rule not url("~/artwork") and put that widget there rather than in default.

Apr 3, 2011 at 6:00 PM

I think the feature he is requesting is valuable. The way you are prescribing it should be done is not flexible enough.

We should be able to see the cumulative view of widgets applied to a specific page and have the choice to subdue a specific widget.


Apr 4, 2011 at 1:13 AM

The way layers work is extremely flexible. You can easily program your own layer rules for any need you might have.

We are only given a couple of basic layer rules out of the box; the Url rule, and an authentication rule.

It would be very easy to modify the Url layer rule to make a "not url" rule which would enable madcapnmckay's scenario. You would then be able to submit this code back to the project for others to use :)

The feature you are describing is actually very tricky and there are a lot of factors and different ways people might want it to work. It's very useful that layers are cumulative; but occasionally needing widget x to override widget y in certain specific circumstances is very difficult to present meaningfully in a UI. But the ability to just insert our own logic for these edge cases is far more useful!

Apr 4, 2011 at 10:13 PM

Pete: you don't even need to create a new rule, as operators can be applied to the rule conditions. not url("~foo/*") works today.

Jonathon: in 1.1, you can turn layers on and off at the click of an icon, it's fast and efficient. We cannot possibly tell in advance what layers will be active for a given url (and the UI for that would be quite clunky) save navigating to the URL in question because we don't know what the rules are relying on, and it wouldn't even be covering the general requirement. Example: the authenticated rule does not depend on the URL at all.

I think the initial demand was for a way to inhibit widgets that are in another layer based on a condition. That would be a new feature that could be built as a module but that is also easily worked around by applying the method I described above.