Layer Selector for Content Items

Topics: Customizing Orchard
Dec 15, 2014 at 5:03 PM
I have preset layers with widgets in them that I would like the users to be able to add to pages they create by a simple dropdown box/select list. Basically the layers and widgets are already created but I want a way for users to be able to select which layers should be applied to the page via a dropdown box and then orchard will automatically add the url for the page being created to the rules for the layer(s) specified. I was thinking of creating a content part that could be applied to a page that lets the user select what layers they would like applied to the page and then it will add the necessary url to the rules for any layers selected. My problem is I don't know where I should put the actual code for adding the new rules to the layers selected. Can this be done in the driver or will I need to make a controller to accomplish this? Thank you.
Dec 15, 2014 at 6:37 PM
Well, you'd have a custom rule (look at the code for existing layer rules such as the url rule), something like custom, for those special layers. At runtime, the rule would evaluate the name of the layer, would look for the current content item, and then would look for that special part, and only activate the layer if those match.