This project is read-only.

Defining widgets at a page level

Topics: Customizing Orchard
Jun 2, 2011 at 8:28 PM
Edited Jun 2, 2011 at 8:29 PM

I think what I would like to do is define widgets at a page level, rather than layer level; however, if I have my concepts wrong, please feel free to correct me.

Here's the idea. I will have many "article" pages on my site, all coming from the same layout, with sidebar zones on the left and right. When a user creates a page, I'd like them to be able to specify which of a pre-existing set of marketing blocks they'd like to drop in the sidebar zones. 

I would prefer to do this without creating a layer for each page, as my pages will number in the hundreds, and that seems like it will make layer management problematic. Also, 99% of the time, they will just be pulling in a widget that exists on multiple other pages, so I don't want them to have to copy the html from an existing html widget into their new layer definition. I'd rather they can just say "on this page, in the left sidebar, I want the 'Did you know' widget, and on the right sidebar, I want the 'store locator' widget", for example. 

I think I could accomplish it using one layer per widget, and building some sort of rule that gets defined on a page (in a user friendly manner) so that each widget's layer can determine if it should display or not...but this seems like a mis-use of layers, and would lead to 2 or 3 dozen unnecessary layers.

The concept I think is pretty similar to randompete's Layout Selector, but applying to widgets instead of layouts.

1. Do I have my concepts right? Should I be using something other than widgets at a page level to accomplish this?

2. Does anyone know of an existing module that accomplishes something like this?

3. If not, can anyone give me a push in the right direction on how one would implement a module like this?

Thanks for your help! 

Jun 2, 2011 at 8:43 PM

That's something we've considered many times, and the only reason it hasn't been done really is lack of time. The page layer hints are a temporary mitigation. The architecture is for sure open to that sort of thing.

Jun 2, 2011 at 9:34 PM

My Paperclips feature does this (in the Mechanics project). It allows you to join content to other content, and have that content show up in different zones when the content is displayed. Since widgets are just content, they can be included too. So, e.g., you join a Page content item to a MapWidget using a Paperclip connector, and hey presto it goes in whatever zone you've defined ;)

Jun 3, 2011 at 3:45 PM

randompete, Paperclips looks like exactly what I want. I don't know how you guys do it...every time I find what I think is a shortcoming or problem in Orchard, one of you has already solved it for me. Thanks a ton!

Jun 3, 2011 at 4:40 PM

Orchard is a great foundation that's really easy to build new functionality on top of, once you get to grips with the inner workings. So lots of great new modules are appearing all the time! I needed a certain set of features for websites I'm building, and luckily I came up with a way to do it that made it easily solve a whole load of other problems at the same time. Mechanics is still not totally finished and I haven't written anything like enough documentation; so if it doesn't seem obvious at first how to use it, give me a shout and I'll walk you through. Once you get your head around how Sockets and Connectors work, it makes complex n-n relationships a piece of cake. I'm nearly ready to release a new version which will sort out a few situations when it comes to templating the various components. Just an installation note: install Origami first, then Mechanics - otherwise you'll get a compilation crash due to the dependency. Can't do anything about this unfortunately; you get the same problem with Voting and Stars modules for instance.

Jun 3, 2011 at 5:14 PM

Peter, Can't you solve the dependency issue using Recipes ?

Jun 3, 2011 at 6:57 PM

Yes I can provide recipes - but there's no option to upload recipes to the gallery, so the problem will still happen for anyone who installs my module directly from there.