2

The site I'm currently building has a dynamic sidebar. I want the user to make a decision about what gets displayed in the sidebar in the channel content.

I am currently using structure, so I have a channel called pages. Under that I wish to have a tabs which allows the user to select different widget options and order them.

I also need the ability to add my own custom widgets.

I have tried the add on widgets but this seems to only allows me to set up different widget categories and i dont feel doing one for each page would make editing of the page clear to the end user.

Any thoughts on add ons or if the widgets addon can be added to the channel field options.

2 Answers 2

4

Could you use Matrix & Playa to solve this?

Your Matrix field would let you add any number of sidebar widgets to the page as rows in Matrix. You can configure the Maximum Allowed Rows if you want to limit the number of sidebar widgets you associate.

Within each Matrix row, your Playa field can be used to relate widget entries from their own Sidebar Widgets channel. You can manage those via Structure under the Assets tab, giving them appropriate widget/sidebar fields and templates.

Updated:

Instead of selecting Widget entries in your Playa field, you can configure Playa to choose from other channels: People, Blog Posts, Videos, etc.

Within your Widget template, have a series of conditions:

if channel==people
...
if channel=blog
...

Then you pull the appropriate excerpts, images, etc from those respective channel entries, and format the widget appropriately for that content.

I've done this many times in the past, and we're doing it on a current project with a different CMS: Store the "promo" or widget content on the entry you're linking to, and pull that specialized content through a sidebar/widget template wherever you've specified to promote that content.

We used this approach throughout this site: http://massgeneralcenterforglobalhealth.org

8
  • Not sure if this approach is OTT. This was my idea: I already have the content I wish to publish in the side bar in there own channels, for example "people". This channel is also used on a page. The sidebar would provide an excerpt of the information. I would just template each widget up in snippets and an include would make the decision on which one to show based on the order and selection given in the channel->page entry.
    – Millard
    Jan 25, 2013 at 15:00
  • Hey Tom, I updated the answer to address those goals. Jan 25, 2013 at 15:05
  • cool thanks, I will give playa a go and see if this addresses my problem. Will update with results.
    – Millard
    Jan 25, 2013 at 15:15
  • +1 for just doing this all with Playa and as many channels as needed to accomodate the various sidebar content types (you don't necessarily need Matrix). The big advantages of this approach: a) once a sidebar block is published it is re-usable sitewide and only needs updating in one place. b) Playa's drop-panes interface allows drag-and-drop reordering making it really easy for the client to get their sidebar content just the right order per-page.
    – Alex Kendrick
    Jan 25, 2013 at 16:06
  • True, you don't need Matrix with the approach I outlined, with conditional logic based on your channel names. Where I've used Matrix is to have two columns: 1 for the type of widget and 1 for the source/linked entry. Some widgets may not map to an entry. They may be coded to just pull the most recent blog post. Others may be type:Photo Gallery, and require choosing a Photo Gallery entry. Jan 25, 2013 at 16:09
0

I usually use a relationship field (either built in or Playa) as mentioned here already, but you could also use a custom field on each entry. Then, your sidebar channel tag could use the search parameter to pull in ones with the custom field "sidebar" or whatever you assign. This works fine, but each is managed on it's own, while using a relationship field lets you do them all at once.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.