homebox ignores block language settings provided by i18n_block

Created on 12 September 2018, almost 6 years ago
Updated 31 October 2023, 8 months ago

The homebox dashboard would be strengthened for multilingual websites if the functionality of i18n_block would be incorporated. This module allows blocks to translated and/or shown only for selected languages. Homebox currently ignores these settings.

  1. Homebox shows the block in the default language and disregards the content language
  2. never excludes a block if it is not supposed to be shown for the current language.

I altered the beginning of the _homebox_can_view_block function in homebox.module to prevent the blocks with the wrong languages to show. I have no idea, however, if this is the appropriate approach. (Checking if the i18n_block_language table exists might be advisable.)

function _homebox_can_view_block($block) {
  global $user;
  global $language_content;

  // Detect valid blocks in the system.
  $valid_blocks = &drupal_static(__FUNCTION__ . ':valid_blocks');
  if (!is_array($valid_blocks)) {
    $valid_blocks = array();
    $results = db_query("SELECT b.module, b.delta, i18n.language FROM {block} b LEFT JOIN {i18n_block_language} i18n ON b.delta = i18n.delta");
    foreach ($results as $record) {
		if (!(isset($record->language))||($record->language == $language_content->language)){
            $valid_blocks[$record->module][$record->delta] = TRUE;
        }
    }
  }

Obviously, this only tackles halve of the issue. Please, let me know, how to proceed and how I can help with the rest.

Thanks
Medemer

πŸ“Œ Task
Status

Closed: outdated

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Cleaning up very old issues. Feel free to reopen, if anyone wants to work on a fix and provides a MR! :)

Production build 0.69.0 2024