Assign a block to more than 1 region
Asked Answered
T

2

9

How do I assign a block (the very same block) twice or thrice to different regions? The idea is not to have the same block on the same page more than once, but in different locations on different pages, so four 'displays' would be available:

  • Block X in the $top_left region
  • Block X in the $top_right region
  • Block X in the $above_content region
  • Block X hidden

Where it should be located, should be as simple as adding node paths in the textare, right? I understand that's what it's for...

If it's a module (please god no, not another module!), I'd like a few details.

Thanks.

Trenttrento answered 21/8, 2010 at 12:42 Comment(3)
What method do you aim to use to determine which page you are on, and therefore where the block will show? For example, do you want to show the block in a different location by content/node type? Or based on part of the URL?Lest
drupal.org/project/multiblock module do the job.Strategic
CitrusTree, the page/location is enough information. That's what I use for blocks. Sometimes even only <front> and [the rest]. So based on the URL. Like with the textarea that's standard in the standard blocks page.Trenttrento
B
13

You'll want to look into the Context module, which will let you assign blocks based on sets of conditions. You create a context, set up a couple of conditions, then create a reaction to those conditions where your block appears.

So, let's say you wanted to show Block X on the front page and when a user is logged in. When it's the front page Block X is in Region 1, but when the user is logged in, Block X is in Region 2.

You'd create two contexts:

  1. Conditions: Is Front Page, User is anonymous, Reactions: Show Block X in Region 1
  2. Conditions: User is logged in, Reactions Show Block X in Region 2

I'm generalizing here, but you'll see what conditions and reactions are available for use when you install Context.

Balzer answered 21/8, 2010 at 20:31 Comment(3)
I've heard about Context, but couldn't find where to setup those blocks. I understand the conditions. Very clear. Sounds like it should have been a Drupal core module. Where can I find the Context's interface? :) ThanksTrenttrento
If you downloaded it, besides Context, you need to enable Context UI. Then, you can access the the UI at Site Building -> Context.Balzer
By the way: I tried Context but there's a conflict or something if you use Zen as a basetheme (and there's a fix which I used and now I love Context!)Trenttrento
Z
0

We can make use of Multiblock module rather than using context. It serves your purpose better

Zwick answered 22/4, 2014 at 6:24 Comment(1)
Context was perfect. Multiblock has new moddelta's, so block class etc have to be duplicated too.Trenttrento

© 2022 - 2024 — McMap. All rights reserved.