For a recent project, we had to extend this module. We have a situation where there are managers responsible for each domain, and we want to give them control over the blocks for their domain.

In order to do this, we extended the module to include the following:

  • Permission to administer own domain blocks
  • When someone with this permission goes to the block configuration for their domain, they see just the blocks that are assigned to their domain. They can rearrange those blocks, and add new custom blocks.
  • People with this permission have no control over blocks 'assigned to all domains'
  • If a site administrator assigns non-custom blocks to a domain (eg book navigation or views blocks), the domain manager can override the position, visibility and title for their domain.

As, is the module is not immediately ready for merging with your existing code, even though I have it on a production site.

  • It is still only Domain Access 2.x compatible (need to merge in recent changes on your end)
  • Right now, blocks assigned to all domains don't appear at all in the block overview page for non default domains. It would be better if they appeared, but were somehow frozen out so they can't be edited.

However, im attaching it here, to see if you think its a good idea to combine efforts. If you do, then I can get to work on creating patches etc.

Comments

nirbhasa’s picture

StatusFileSize
new18.54 KB

Attaching file :)

nonsie’s picture

Status: Needs review » Needs work

Thanks! This is something I've been thinking about adding to the mix.
I noticed you also added theme, region and weight to blocks instead of inheriting those from the base blocks. What was your reasoning behind that?

nirbhasa’s picture

That is so people with the 'administer own domain blocks' permission can assign blocks to regions on a per-domain basis.

nirbhasa’s picture

StatusFileSize
new17.22 KB

This is an updated version - I had some cruft in there that needed to be removed

nirbhasa’s picture

StatusFileSize
new18.79 KB

Yet another update, this time I fixed some things...

- Now you can choose to show 'domain site' blocks on domain-specific forms, however they cant be edited except from the default domain and will be greyed out on other domains
- Deals with invalid regions much better now
- Some options on the main domain settings page

Now the only thing left is to merge it is 3.x compatibility. From my end, this might need to wait for a couple of other things, although I will get back to it in due course.

nirbhasa’s picture

Actually...the showing 'domain_site' blocks on the overview page for each domain is not working out so great. Basically, I tried to leave the weight of the domain_site blocks untouched, and have the other domain specific blocks compensate around that. Unfortunately it doesnt seem to be working out too good. Also there will be the issue the effect on the other domains when the block is modified in the default domain.

So the only real way to do it is probably to assign a per-domain weight for each 'domain_site' block - in other words, they can't move out of the region, but they can move around within that region. However, im not sure we really want to be filling up the table with lots of domain_site entries. I was thinking about a variable array to hold the domain weights, or maybe a seperate per-domain variable array which only gets created when necessary.

It would be good to get your thoughts before proceeding further.

matt b’s picture

I found the Nodes in Block module really useful for a similar situation - doesn't give your site managers total control over the blocks on their sites, but allows them to put content into the block regions.

nonsie’s picture

I really like the idea of such functionality but the reality is that it will have to be a minor version instead of the current 7.x-3.0 since it introduces something fairly different from current functionality and what the module has historically done.

So here's the wishlist:

  • Option to control block display per theme (change region and weight per domain), alter block title per domain, alter block visibility per domain.
  • Option to grant permission to administer own domain blocks:
    • People with this permission on block configuration for their domain control just the blocks that are assigned to their domain. They can rearrange those blocks per theme and region, change weight within region, change block title and visibility.
    • People with this permission can add new custom blocks to their domain only and rearrange those blocks per theme and region, change block title and visibility.
    • People with this permission have no control over blocks 'assigned to all domains' in terms of position(region) but they can alter the weight of the block within a region.

From code perspective this means that for each block we need to store region, weight, visibility, pages and title just like core block module does.

Current implementation of the module does not care about individual instances of the block in different themes. A block is granted permissions based on the module and delta not the individual block id/theme. This would need to be altered to make permissions based on block instance within a theme (bid in {blocks} being a good identifier).

Here's possible steps to tackle this:
1. convert module to use bid and respect theme settings. Requires {domain_blocks} table update to add bid and theme field and an update to update all blocks currently in {domain_blocks}.
2. add support for status, weight, region, visibility (content types, pages, roles, users) and title
3. build out new UI to support #2
4. build out new UI to support "administer own domain blocks" permission. I anticipate this will get quite confusing when people can manage more than one domain.

Aptalops’s picture

wow, the wish-list corresponds with exactly what I would need. Signing up...

nirbhasa’s picture

StatusFileSize
new19.96 KB

Just revisiting this issue after a long time. Heres my latest version, which deals with the domain_site issue above. It seems to work ok with 3.x, although I haven't done a huge amount of testing. Just including in case it may be useful at some point.

berenddeboer’s picture

Have done quite some work on this patch.

berenddeboer’s picture

Status: Needs work » Needs review
berenddeboer’s picture

carlitus’s picture

This is awesome feature but it seems that it doesn't work with #11, the latest 3-dev version and Drupal 7.76

The error is:
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'theme' in 'where clause': SELECT DISTINCT domain_blocks.module AS module, domain_blocks.delta AS delta FROM {domain_blocks} domain_blocks WHERE (theme = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => ipress ) a domain_blocks_get_all_customised_blocks() (línia 970 de /var/www/html/sites/all/modules/domain_blocks/domain_blocks.module).