This week's Weekly Drupal is about blocks. In our project, where we are migrating 70 websites into Drupal as indicated here, we will be using many blocks to create panels in various regions of our theme. So, a question has come up that we assumed Drupal must have an easy solution for: how to control block visibility per page.
For example, we want our 70-odd webmasters to be able to turn on/off blocks in the context of a given page. It seems the only built-in way to do this, as the default behaviour for blocks is for them to be displayed site-wide, is to use this part of the block configuration:

which we find to be not so user-friendly. Ideally, when users create content for their site(s), they should be able to specificy which blocks should appear on the page they are creating AT the time of creation.
So, we did a little research and chatted with our consultant and have as of yet not found any pre-existing modules that easily facilitate this. Odd, considering that it seems like something many people would prefer for their Drupal sites.
So, for now, we're looking at options such as using CCK fields that control this behaviour per page with some php that tells the block to appear. Or, we'll simply provide very detailed training on how to use the configure option above and list the pages where a particular block should appear, though I could imagine this getting VERY cumbersome if you have 100 or 1,000s of pages on your site.
The Weekly Drupal is a weekly column on mavergames.net about Drupal from the perspective of a new user. Use this feed to subscribe.
Context Module
By Alex Dergachev (not verified)The context module does exactly what you're looking for. It's a relative newcomer, but it's picking up a tremendous amount of momentum in the community, thanks to the need it fulfills, and the renown of Development Seed, the Drupal shop that created it.http://drupal.org/project/context
If each individual page has
By MacRonin (not verified)If each individual page has to have the option of unique blocks, a CCK field(checkbox against a list) would probably be the best choice. Having users coding the PHP themselves is asking for trouble. One typo could kill all page displaysI haven't been able to explore them deeply yet. But from the doc I've seen it looks like two modules from DvelopmentSeed may be able to help.( At least if you ant the blocks to appear on groups or types of pages) The are on D.O and name Spaces and Contexthttp://drupal.org/project/contexthttp://drupal.org/project/spaces
Agreed.
By joshmiller (not verified)After developing 15 web sites with Drupal 6 for the last year, I too have struggled with block visibility in-flexibility.
In fact, my first Drupal web site I spent days trying to figure out what you're talking about. The solution would have to be three-fold:
1) Blocks would have to be "turned on for page-level activation" -- right now they are only "on" or "off"
2) The Blocks would have to have visibility settings per page. You said it yourself, there could be thousands of pages. All with a granular setting on whether or not to show "exciting callout block"
3) To avoid problematic settings, we would also want to implement this on a per-content-type basis.
Wait a minute! You can control block visibility using http://drupal.org/project/context/. And you can create contexts for content types. -- Not perfect, but a good step forward...
Josh
Context Module
By Jolidog (not verified)Perhaps you should take a look at the context module: http://drupal.org/project/context. It can show/hide blocks and do other tricks acording to the section of the site, insted of the path...
hrm...
By dalin (not verified)I can't think of any recent site that I've built where it would be acceptable to have content creators have control over the page layout.
Not control over layout, but content
By mavergamesHi, No, not control over the layout. The blocks appear in a region of the theme specified by us. But, we want users to be able to create a page and say "show those particular prepared blocks of content (RSS feeds, standard link collections, or their own "related resources" links)" for THAT page only.
re: block visibility per page
By Christopher Pelham (not verified)Panels/CTools is designed, in part, to address this issue as it allows for a page-centric model of content layout. Panels still requires a two-step process: create a new node; add that node to a page along with the desired blocks. However, in Panels 3 templates can be set up whereby nodes, when displayed as pages, are automatically displayed instead with a Panel template. So this could work for you if your users can make use of templates and do not instead require different blocks on each page which do not conform to any patterns. Does that make sense?
Thanks!
By mavergamesThanks to all for "Context module" suggestion. We'll check out it!Cheers,Chris
I have a one block - user's
By nike dunk (not verified)I have a one block - user's online Now if i want that block on different region in different page. does region really helpful to me and how? For example: Front page i need in the 'Left Sidebar' Inner page i need in the 'Right Sidebar'.
Post new comment