Hi,
Just for page types, not other content types, the alias comes out wrong, I get:
create-page
create-page-0
etc, works fine for other content types.
Am using 7.12 with php 5.2.6-1+lenny16.
Yes I have tried todays dev version.

Comments

stephenrobinson’s picture

Oh yes alias is "content/[current-page:title]"

stephenrobinson’s picture

debug on:
$path = _pathauto_set_alias($path, $existing_alias, $op);
drupal_set_message('path=

'.htmlspecialchars(print_r($path,1)).'

');
returns:

path=
Array
(
    [source] => node/4070
    [alias] => create-page-6
    [language] => und
    [pathauto] => 1
    [original] => 
    [pid] => 15317
)
stephenrobinson’s picture

Issue is with token_replace() in core includes, returns this bad value.

  $replacements = array();
  foreach ($text_tokens as $type => $tokens) {
    $replacements += token_generate($type, $tokens, $data, $options);
    if (!empty($options['clear'])) {
      $replacements += array_fill_keys($tokens, '');
    }
  }
drupal_set_message('replacements=<pre>'.htmlspecialchars(print_r($replacements,1)).'</pre>'); // debug...
replacements=
Array
(
    [[current-page:title]] => create-page
)
stephenrobinson’s picture

[current-page:title] does not work when creating pages, works for other content types, as it takes the title of the node/add/page, not the title of the page you are creating?

stephenrobinson’s picture

think this has to do with token_generate:
$replacements = module_invoke_all('tokens', $type, $tokens, $data, $options);

stephenrobinson’s picture

latest theory involves sites/all/modules/contrib/token/token.tokens.inc

stephenrobinson’s picture

found a fix, will create issue for token module, see http://drupal.org/node/1442420.
line 648 on:

    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'title':
          $title = drupal_get_title(); 
          if( (arg(0)=='node') && (arg(1)=='add') && (arg(2)) && (!arg(3)) ) { // added
            $title = filter_xss_admin(check_plain($data['node']->title));// added
          } // added
dave reid’s picture

Status: Active » Closed (works as designed)

The token is working as designed. The title of node/add/page is in fact "Create page."

stephenrobinson’s picture

Hi,
All that means is you have to edit and save the node to get the correct alias.
It is a useful token for use with pathauto.
I guess I will patch it for my own use....
Stephen :)

dave reid’s picture

If you're trying to use the node title in the Pathauto pattern, why aren't you just using [node:title] instead of [current-page:title]?

stephenrobinson’s picture

Ah yes, that works, was not listed on /admin/config/search/path/patterns in the section "Replacement patterns". Thanks for the info, perhaps there is a node section missing?

stephenrobinson’s picture

Ah me being stupid again, have to check all the "Replacement patterns" sections, not just the bottom forum one, sorry,
S:)