When og_menu creates a new menu in og_menu_node_insert(), it calls menu_save(). Right now if a site wants to have those menus be translatable by default, they would probably have to implement a hook_menu_insert() to set the menu properties i18n_menu cares about. The problem is that $menu is an array and not one that can be altered by reference. So in order to get it to work you would have to ensure your modules hook happened after i18n_menu_menu_insert() and basically copy all the code from that into your hook once you set the right i18n_mode.

Instead it would be nice to allow administrators to set the default mode for new menus.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jojonaloha’s picture

Status: Active » Needs review
FileSize
2.85 KB

The attached patch creates a new setting on the OG Menu configuration form (/admin/config/group/og_menu) when i18n_menu is enabled.

It also updates the hook_node_insert() and hook_node_update() implementations to set the default mode before calling menu_save().

jojonaloha’s picture

This updated patch also updates the og_menu_edit_menu_form() to include the i18n_menu elements, otherwise saving the form from the og menu edit page will lose these settings.

rv0’s picture

Component: Code » OG Menu i18n

Bundling all i18n related issues.

fuerst’s picture

Patch #2 works, although I'm not sure if saving the default at a group node update in og_menu_node_update() is what one would expect. That way any menu customization will be set to the default again.

fuerst’s picture

Something like that can be used to update existing menus which still are set to I18N_MODE_NONE.

/**
 * Set translation settings at OG menus.
 */
function my_module_update_7000(&$sandbox) {
  db_update('menu_custom')
    ->fields(array('i18n_mode' => variable_get('og_menu_default_i18n_mode', I18N_MODE_NONE)))
    ->condition('menu_name', 'menu-og-%', 'LIKE')
    ->condition('i18n_mode', '0')
    ->execute();
}
rv0’s picture

never count on the menu name always being "menu-og-"
any menu can be attached to a group

rv0’s picture

Status: Needs review » Closed (duplicate)
Related issues: +#2348821: OG Menu i18n combined patch