In source code we have old d6 function versions

/**
* Implementation of hook_token_list().
*/
function i18n_menunode_token_list($type = 'all') {
if ($type == 'node' || $type == 'all') {
$tokens['node']['i18n-menupath-raw'] = t("The unfiltered menu path (as reflected in the breadcrumb), not including Home or [menu]. Separated by /.");
return $tokens;
}
}

/**
* Implementation of hook_token_values().
*/
function i18n_menunode_token_values($type, $node = NULL, $options = array()) {
$values = array();

if ($type == 'node') {
$trail_raw = array();
$item = FALSE;

// If the current node has no menu item we use the source node one.
if (empty($node->menu['mlid'])) {
$tnid = _i18n_menunode_get_node_tnid($node);
if (!empty($tnid) && $tnid != $node->nid ) {
$tnode = (object) array('nid' => $tnid);
//_i18n_menunode_prepare($tnode);
menu_node_prepare($tnode);
// We use the source node menu item only if node translation is enabled.
$item = !empty($tnode->menu['mlid']) && i18n_menunode_enabled($tnode->menu) ? $tnode->menu : FALSE;
}
}
else {
$item = $node->menu;
}

while ($item) {
array_unshift($trail_raw, _i18nmenu_get_item_title($item, FALSE, $node->language));
$item = empty($item['plid']) ? FALSE : menu_link_load($item['plid']);
}

$values['i18n-menupath-raw'] = !empty($options['pathauto']) ? $trail_raw : implode('/', $trail_raw);
}

return $values;
}

What we need to change to make it works in d7??

CommentFileSizeAuthor
#3 add-token-support-1566002-3.patch757 bytesdpacassi

Comments

andrewc.swanson’s picture

Version: » 7.x-1.x-dev
Status: Active » Needs review

D7 removes the old menupath-raw tokens and replaces it with something like [node:menu-link:parents:join-path]/[node:menu-link]. I have followed these new conventions in the i18n_menu_node implementation, using an array token. In the latest dev channel, I added a new [node:menu-link-i18n] token. While the default menu link separates parents from the active item, the translated version doesn't. The token that will replicate ['i18n-menupath-raw'] is now [node:menu-link-i18n:join-path].

Also, a new dev release should be getting pushed by tomorrow in case you aren't using the dev channel straight from Git.

gillesv’s picture

The function/hook "i18n_menu_node_tokens" seems to be currently implemented in this Drupal 7 version of "Menu translation - Node", but there seems to be an issue that is causing errors.

On line 597 of the current DEV version of "i18n_menu_node.module", it reads:

$tnode = (object) array('nid' => $tnid);
menu_node_prepare($tnode);

But "menu_node_prepare" complains that "$node->type" is not avaiblable.
The error can be fixed by changing the above lines to this:

$tnode = node_load($tnid);
menu_node_prepare($tnode);

But I'm not sure if this fixes everything?

dpacassi’s picture

StatusFileSize
new757 bytes

Instead of loading the whole node, we can also simply add the node type to the $tnode object.
See attached patch for more details.