When using the Menu translation module that is included in the i18n package, primary links cannot be set to active by Context. This is because i18nmenu_preprocess_page() replaces primary links with its own, and is always runs after Context's preprocess function. I tried changing the module weights to affect the order in which the functions are run, but the order remains unchanged. Does anyone know how to get context_preprocess_page() to run last?

Comments

xalexas’s picture

Same thing with i18n Block translation. All blocks defined in context reactions disappears after i18n Block translation is enabled.

dboulet’s picture

xalexas’s picture

It seems it's resolved with i18n 6.1.4

fletchgqc’s picture

I'm running i8n 6.1.4 and I installed context and created a context to set a primary links menu item active and it didn't work.

Then I disabled all the i18n modules and the context condition worked nicely.

So I think the problem of a conflict with i18n somewhere still exists.

xalexas’s picture

Are you using context 6.x-3.0-beta4? What theme are you using?
I have i8n 6.1.4 and Context 6.x-3.0-beta4 with ZEN sub theme and don't have problem anymore. Try to clear cache if you didn't and run update.php.

Everything worked for me after upgrading to i8n 6.1.4.

fletchgqc’s picture

Yes I'm using that version; custom theme from scratch but I checked the HTML and the data wasn't in there. I did what you said and it still didn't work for me. I'm going to leave this issue here because I've figured out I can get the simple functionality I need from the menu trails module. Good luck to the next person.

robertgarrigos’s picture

I'm having this issue with i18n 6.1.4, context 6.x-3.0-beta4 and garland theme. Disabling i18n.menu module "solves" the problem. :-(

kdebaas’s picture

Version: 6.x-3.0-beta4 » 6.x-3.0-beta5
Category: support » bug

I can confirm this incompatibilty. Working with Context 3.0-beta5 and i18n 1.5. Flushing caches didn't help.

danny_joris’s picture

Edit: At first I thought I had the same issue, but I disabled all i18n modules and the issue remained. Posted new issue here: #842250: None of my blocks are showing + blocks stuck in footer region

dboulet’s picture

I found the following code in the JQuery Update module, I think that we could implement something similar to solve this problem:

<?php
/**
 * Implementation of hook_theme_registry_alter().
 *
 * Make jQuery Update's page preprocess function run *after* everything else's,
 * so that a theme can't call drupal_get_js() and mess everything up.
 */
function jquery_update_theme_registry_alter(&$theme_registry) {
  if (isset($theme_registry['page'])) {
    if (count($theme_registry['page']['preprocess functions']) > 0) {
      // If jquery_update's preprocess function is there already, remove it.
      if ($key = array_search('jquery_update_preprocess_page', $theme_registry['page']['preprocess functions'])) {
        unset($theme_registry['page']['preprocess functions'][$key]);
      }
    }
    // Now tack it on at the end so it runs after everything else.
    $theme_registry['page']['preprocess functions'][] = 'jquery_update_preprocess_page';
  }
}
?>
scott859’s picture

subscribing

dboulet’s picture

Title: Incompatibility with i18nmenu module » Make i18nmenu module preprocess primary links first
Project: Context » Internationalization
Version: 6.x-3.0-beta5 » 6.x-1.x-dev
Component: Code » Menus
Assigned: Unassigned » dboulet

Come to think of it, I think that it should probably be up to the i18nmenu module to make sure that its preprocess function runs first. Any other modules making changes to the primary links will have the same incompatibility as Context.

I'll look into this.

dboulet’s picture

Status: Active » Needs review
StatusFileSize
new1.38 KB

This fixes the incompatibility with Context module.

gaia’s picture

applyed this patch and the context module does its job.
but there is another problem now. i have two languages installed and the primary links are all displayed in both languages.

any hints how to solve this?
thanks.

shadysamir’s picture

Subscribe

mmartinov’s picture

I've just applied the patch and it fixes the issue. I've got three languages and for me there are no side effects such as the mentioned by gaia above.

shadysamir’s picture

The patch in #13 did not fix my Context problem

lord_of_freaks’s picture

#13 works for me ... thx a lot

jose reyero’s picture

Status: Needs review » Closed (won't fix)

Just let's make this clear: i18n blocks are not compatible with context module because both modules will clash on multiple places.

(And that is not expected to change for Drupal 6)

shadysamir’s picture

@Jose You mean i18n menu?

EndyBoooj’s picture

@gaia, I had the same problem, but I noticed that not all our items were displayed. only menu items created by modules, not directly from a node. For example, one menu item, linked to a page was hidden, but another item, created by facetted search, was indeed displayed in our menu.

I solved this with a little tweek, copied from the way context alters the theme_registry. I'm not completely sure this is all written the Drupal way but we had to do so, to reach our deadline.

/**
* Implementation of hook_theme_registry_alter().
*
* Make i18nmenu's page preprocess function run *before* everything else's,
* in case they want to alter the primary links.
*/
function i18nmenu_theme_registry_alter(&$theme_registry) {
  if (isset($theme_registry['page']) &&
      FALSE !== $position = array_search('i18nmenu_preprocess_page', $theme_registry['page']['preprocess functions'])) {
    // Remove i18nmenu's preprocess function.
    unset($theme_registry['page']['preprocess functions'][$position]);
    
    // Now tack it right after *template_preprocess_page*, right before context. Because i18n's weight is bigger
    // this will be executed after context's hook_theme_registry_alter().
    $position = array_search('template_preprocess_page', $theme_registry['page']['preprocess functions']);
    $position = $position ? $position + 1 : 2;
    array_splice($theme_registry['page']['preprocess functions'], $position, 0, 'i18nmenu_preprocess_page');
  }
}
lmeurs’s picture

For Drupal 7 I used the code from post #21, but changed the module's name from i18nmenu (D6) to i18n_menu.

Post #21 also uses i18nmenu as a hook, it's better to use your own theme's or module's name.

/*
* Implementation of hook_theme_registry_alter().
*
* Make i18n_menu's page preprocess function run *before* everything else's,
* in case they want to alter the primary links.
*/
function HOOK_theme_registry_alter(&$theme_registry) {
  if (isset($theme_registry['page']) && FALSE !== ($position = array_search('i18n_menu_preprocess_page', $theme_registry['page']['preprocess functions']))) {
    // Remove i18n_menu's preprocess function.
    unset($theme_registry['page']['preprocess functions'][$position]);
    
    // Now tack it right after *template_preprocess_page*, right before context. Because i18n's weight is bigger
    // this will be executed after context's hook_theme_registry_alter().
    $position = array_search('template_preprocess_page', $theme_registry['page']['preprocess functions']);
    $position = $position ? $position + 1 : 2;
    array_splice($theme_registry['page']['preprocess functions'], $position, 0, 'i18n_menu_preprocess_page');
  }
}