Recently Pathauto added a way for hierarchy tokens like 'foo/bar/baz' to have the single segments cleaned separately. We need to support this behavior.

CommentFileSizeAuthor
#1 i18nmenu_node-926130-1.patch2.68 KBplach

Comments

plach’s picture

Status: Active » Needs review
StatusFileSize
new2.68 KB

The attached patch deprecates the [i18n-menuhierarchy-raw] token in favor of the new [i18n-menupath-raw]. The latter conforms to the new standard form introduced by Token and Pathauto in #881270: [bookpath], [menupath], [*path] tokens not cleaned: aliases without punctuation removed, lower casing, etc., to trigger the segment cleaning mode.

plach’s picture

Status: Needs review » Fixed
spuky’s picture

Status: Fixed » Needs work

Hi this patch is not working as expected... i fixed the path issue myself but was to bussy to write a clean patch... (as you did with hint in the instal file...and so on...)

So here are the things that need to be diffrent..

1 when submitting menpath tokens we are suposed to aply pathauto_cleanstring
2 and the token has still to be submitted as 1 string...

since I got no cvs installation on the site I merged my changes with your patch.. and am still rather bussy here is a working version of the i18nmenu_node_token_values function.

If the token will be used as a path the pathauto_cleanstring is applied in any cast the output is a single string...

function i18nmenu_node_token_values($type, $node = NULL, $options = array()) {
  $values = array();

  if ($type == 'node') {
    $value = '';
    $trail_raw = array();
    $tnid = _i18nmenu_node_get_node_tnid($node);
    $tnode = !empty($tnid) && $tnid != $nid ? (object) array('nid' => $tnid) : $node;
    _i18nmenu_node_prepare($tnode);

    if (!empty($tnode->menu)) {
      $item = $tnode->menu;

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

      $value = implode('/', $trail_raw);
    }

    $values['i18n-menupath-raw'] =  $value;
    $values['i18n-menuhierarchy-raw'] = $value;
  }
  return $values;
}
plach’s picture

Status: Needs work » Postponed (maintainer needs more info)

Sorry, but I absolutely don't get what's wrong with the committed patch, you should provide more information about it. Looking at the alternative code you posted I assure you it's not the way the latest stable versions of Pathauto and Token are meant to work. See pathauto.inc (lines 568-574) and token_node.inc (lines 75-83) for reference.

spuky’s picture

Status: Postponed (maintainer needs more info) » Fixed

Sorry for the confusion I hadn't updated token (since 1.5 was not there) when I wrote my code and did not when trying your patch this morning...

your patch is working fine after updating to token 6.x-1.5

Sorry

plach’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.