Is this the best way to use widget layer rule?

Topics: Customizing Orchard
May 2, 2013 at 12:16 PM
Hi Everyone,

I'm starting to experiment with Orchard CMS and widget layar rules.
Assume I got 3 different widget parts, I want each widget to go in the Content Zone.

I use the Default Widget Layar acting like Master Page. While I create 3 different Widget Layar, and have each Widget Layor mapped to each of those widget parts (1 to 1) via Layar rules. Is this the right way?
May 3, 2013 at 3:46 PM
Any thoughts to this?

Thanks.
Developer
May 3, 2013 at 3:53 PM
Edited May 3, 2013 at 3:54 PM
It depends on what you are trying to do.

Examples:
If all you want to do is have 3 widgets appear in the Content zone for the Default layer rule, then you don't need 3 other layers, because a single layer and zone can contain any number of widgets.
If you want 1 of those 3 widgets to appear, for example, on the home page only, then that widget needs to be assigned to the TheHomePage layer.
If you want another one of those widgets to appear on both the ~/contact and ~/about urls, then you create a specific layer with that URL rule and assign the widget to that layer.

As you can see, it depends.
May 3, 2013 at 7:02 PM
Let me then give a more concrete example, and how would you config in this ecommerce Scenario
I have a ~/store and ~/store/details

~/store/* (Default for all subsequent child url)
  • Contains menu_widget (top), productCategory_widget (asidefirst), productList_widget (Content)
~/store/detail
  • should inherit menu_widget, productCategory_widget but NOT productList_widget (Content).
    On this layer it would replace productList_widget with productDetails_widget
How do I achieve this ?
May 3, 2013 at 8:40 PM
There's no way to 'inherit' from another layer. There would just need to be an approach to creating the layers to what would work for you. It is sometimes easier to deal with it from the other direction. Make three layers called "Menu", "product Category" and "Product List". Those layers would tell one widget (or more) when to show up. So in your case, there would be 3(?) layers... one layer for each widget.
Developer
May 3, 2013 at 9:06 PM
Edited May 3, 2013 at 9:06 PM
Or you could have 2 layers like this:

~/store
  • Contains productList_widget (Content)
~/store*
  • Contains menu_widget (top), productCategory_widget (asidefirst)
This way, all 3 widgets show up on both ~/store and ~/store/detail and any other url that starts with ~/store.
At the same time, the produclist widget will only show up in ~/store.
May 6, 2013 at 5:24 AM
sfmskywalker wrote:
Or you could have 2 layers like this:

~/store
  • Contains productList_widget (Content)
~/store*
  • Contains menu_widget (top), productCategory_widget (asidefirst)
This way, all 3 widgets show up on both ~/store and ~/store/detail and any other url that starts with ~/store.
At the same time, the produclist widget will only show up in ~/store.
This did the trick. Thank You.