This is a very simple patch that just adds db_rewrite_sql to the block list query.

This will allow to implement per-language selection of blocks and maybe some other uses. In general, it gives contributed modules control over which blocks are shown for each page.

Comments

moshe weitzman’s picture

Status: Active » Needs review

i'm not so sure about this. i think it is a slippery slope. if we want general hook for modules to rewrite sql, we should add it to db_query() and be done with it. i'm curious to hear opinions from chx and others. also, i don't know how you plan to use this, and thus am unsure how it will interact with the user's block visibility settings.

wim leers’s picture

Subscribing.

jose reyero’s picture

Moshe,

i'm not so sure about this. i think it is a slippery slope. if we want general hook for modules to rewrite sql, we should add it to db_query() and be done with it. i'm curious to hear opinions from chx and others. also, i don't know how you plan to use this, and thus am unsure how it will interact with the user's block visibility settings

About the rewrite sql hook, it's already there, and it's all we have for now, so... I think this kind of adds consistency to the whole thing as this blocks query is one of the few listing queries not using it...

The way I plan to use this is:
- table block_language(bid, language)
- use forms api to show a language field for custom blocks
- then add the query join with hook_db_rewrite_sql().

The problem with blocks for multilingual sites are not the ones produced by modules, but the custom boxes you can create, and currently we have no way to translate it, so if only we could add them a language field and then use this to select blocks per language....

However this doesn't enforce any particular solution on Drupal core, it just leaves the doors open for contributed modules.

merlinofchaos’s picture

I think this is the kind of thing db_rewrite_sql is meant for.

webchick’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1.67 KB

I agree.

Patch still applies, but wasn't rolled from root. Also, missed adding this change to the documentation of db_rewrite_sql. I also took the opportunity to wrap that line to 80 chars.

Marking RTBC, per merlin's comment.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed!

Anonymous’s picture

Status: Fixed » Closed (fixed)