function hook_mongodb_block_ui_info_alter in MongoDB 7
Act on mongodb_block_uis prior to rendering.
This hook allows you to add, remove or modify mongodb_block_uis in the mongodb_block_ui list. The mongodb_block_ui list contains the mongodb_block_ui definitions not the rendered mongodb_block_uis. The mongodb_block_uis are rendered after the modules have had a chance to manipulate the mongodb_block_ui list. Alternatively you can set $mongodb_block_ui->content here, which will override the content of the mongodb_block_ui and prevent hook_mongodb_block_ui_view() from running.
This example shows how to achieve language specific visibility setting for mongodb_block_uis.
Parameters
array $mongodb_block_uis: An array of $mongodb_block_uis, keyed by $bid.
File
- mongodb_block_ui/
mongodb_block_ui.api.php, line 262 - Hooks provided by the Block module.
Code
function hook_mongodb_block_ui_info_alter(array &$mongodb_block_uis) {
global $language, $theme_key;
$result = db_query('SELECT module, delta, language FROM {my_table}');
$mongodb_block_ui_languages = array();
foreach ($result as $record) {
$mongodb_block_ui_languages[$record->module][$record->delta][$record->language] = TRUE;
}
foreach ($mongodb_block_uis as $key => $mongodb_block_ui) {
// Any module using this alter should inspect the data before changing it,
// to ensure it is what they expect.
if (!isset($mongodb_block_ui->theme) || !isset($mongodb_block_ui->status) || $mongodb_block_ui->theme != $theme_key || $mongodb_block_ui->status != 1) {
// This mongodb_block_ui was added by a contrib module, leave it in the
// list.
continue;
}
if (!isset($mongodb_block_ui_languages[$mongodb_block_ui->module][$mongodb_block_ui->delta])) {
// No language setting for this mongodb_block_ui, leave it in the list.
continue;
}
if (!isset($mongodb_block_ui_languages[$mongodb_block_ui->module][$mongodb_block_ui->delta][$language->language])) {
// This mongodb_block_ui should not be displayed with the active language,
// remove from the list.
unset($mongodb_block_uis[$key]);
}
}
}