First off, I'm not sure where the "right" place to post this is, whether it's in Page Title, Token or Pathauto, BUT, I've been able to replicate the same problem, over several installs.

Assuming all three modules are installed: Page Title, Token & Pathauto
Assuming content type is: newpage
Assuming page title for a newpage node is: this is a new page!

I set the node pattern for a content type to: newpage/[page-title-raw] so the url alias will be pulled from the page title, instead of the node "heading" or node title.

When I create a node of the content type "newpage", plugin my page title and save the node for the first time, I get a URL alias of: /newpage/create-newpage instead of /newpage/this-is-a-new-page

Now, if I go back in and edit that same node, go to URL Path Settings, the "Automatic Alias" is unchecked. Once I check it and save the node, it creates the proper URL alias of: /newpage/this-is-a-new-page

Has anyone else experienced or been able to duplicate this? Also, is it a page title, token or pathauto issue?

#12 page_title-node-1015130-12.patch1.37 KBtheunraveler
Members fund testing for the Drupal project. Drupal Association Learn more


philsward’s picture

Version: 5.x-2.x-dev » 6.x-2.x-dev

Yeah, wow... I guess I forgot to set the version and what-not on this issue... The codebase for this is with Drupal 6.x, not 5.x. Changing to the 6.x version

TJEngel’s picture

I am experiencing the exact same issue, although I am using the non-dev 6.x-2.3 version of Page Title. I have also been able to replicate the issue multiple times by performing the workflow outlined above. I am using the [page-title] replacement pattern in my PathAuto settings.

I am also unsure whether this is a Page Title, Path, PathAuto, or Token issue. Confirming that I am able to duplicate.

entrigan’s picture

Likewise. The issue is that token for page-title gets the node object by calling menu_get_object(), which is not a node if the page is node/add/*

To remedy this I have modified the page-title tokens as follows:
modify function function page_title_token_values() to add a token of type 'node'

function page_title_token_values($type, $object = NULL, $options = array()) {
  $values = array();

  if ($type == 'global') {
    $values['page-title'] = page_title_get_title($type, $object, $options);
  elseif ($type == 'node') {
    $values['page-title'] = page_title_get_title($type, $object, $options);

  return $values;

Then modify the function page_title_get_title() as follows:

function page_title_get_title($type, $object = NULL, $options = array()) {
  //If a new node is being created we will have access to, and need to use the $object variable to find the page_title.
  if(arg(0) == 'node' && arg(1)== 'add'){
    $title = $object->page_title;
  // If we're looking at a node or a comment on a node, get the node object from the menu system.
  elseif ((arg(0) == 'node' && is_numeric(arg(1)))  ||  (arg(0) == 'comment' && arg(1) == 'reply' && is_numeric(arg(2))) && module_exists('comment')) {
    $node = menu_get_object();

Sorry for not having a patch. This is most likely not a perfect fix, as I have never written token integration before I wrote this somewhat blindly. Perhaps there should be a different function to handle the node token? It however does work.

TJEngel’s picture

entrigan, just wanted to say thanks and that this is an effective workaround. I am not enough of an expert to know if this would be considered a "best practices" fix, but able to confirm that yes, it does solve the issue.

entrigan’s picture

Ok since we have not heard from maintainers, I have gone ahead and rolled this into a custom module. code is as follows: (middle function is not really necessary)

function mymodule_token_values($type, $object = NULL, $options = array()) {
  if ($type == 'node') {
    $tokens['node-page-title'] = mmymodule_get_page_title($object);
    return $tokens;

function mymodule_get_page_title($object = NULL){
  $title = $object->page_title;
  return $title;  

function mymodule_token_list($type = 'all') {
  if ($type == 'node' || $type == 'all') {
    $tokens['node']['node-page-title'] = t("The node's page title'");
    return $tokens;
philsward’s picture

Since I'm a programing idiot, I'm going to ask a bit of a dumb question here... Who exactly would be responsible for getting this fixed? The "Page Title" folks or the "Token" folks? If it's the token folks, I'll get a post going over in their queue.

entrigan’s picture

Page Title is responsible. Just needs to implement an additional token for node page titles.

ranavaibhav’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev

Issue persists in 7.x version as well. #5 doesn't seem to be valid for 7.x branch.

Echo initial post (Posted by philsward on January 4, 2011 at 7:00pm), however the token is: [current-page:page-title] for 7.x

jeffwidman’s picture


sillygwailo’s picture

Here's the first stab at the Drupal 7 equivalent of #5 (which I'm grateful for in a D6 project).

Replace 'modulename' with the name of your custom module. Also make a note to update the token's description text so that you can find the code later when looking at it in an administrative interface. Most of the code is from core's

function modulename_token_info() {
  $info['tokens']['node']['page-title'] = array(
  	'name' => t('Page title'),
  	'description' => t("Title as processed by the Page Title module. (Token provided by YOUR MODULE'S NAME.)"),
  return $info;

function modulename_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $url_options = array('absolute' => TRUE);
  if (isset($options['language'])) {
    $url_options['language'] = $options['language'];
    $language_code = $options['language']->language;
  else {
    $language_code = NULL;
  $sanitize = !empty($options['sanitize']);
  $replacements = array();

   if ($type == 'node' && !empty($data['node'])) {
     $node = $data['node'];
     foreach ($tokens as $name => $original) {
     switch ($name) {
        case 'page-title':
          $title = ($node->page_title) ? $node->page_title : $node->title;
          $replacements[$original] = $sanitize ? check_plain($title) : $title;
  return $replacements;
nicholasThompson’s picture

Assigned: Unassigned » nicholasThompson
Category: support » feature
Priority: Normal » Major
Status: Active » Needs work

Sorry for not looking into this - I have been away from my issue queues recently as my wife and I have had a baby (which takes priority, I'm afraid! ;-) heh).

This is an interesting bug as I'd never expected people to use the Page Title for the URL. I guess it makes sense...

As you have also pointed out, the problem is that the token scope doesn't exist yet. I'll try running some tests against #1015130-3: Page Title Token Won't Create Pathauto URL Alias On First Save as it looks like a sensible enough solution. I sometimes wish Drupal had a better context detection system. ;-)

theunraveler’s picture

Here's a patch for the D7 fix in #10, with a few additional improvements.

sillygwailo’s picture

Status: Needs work » Needs review
interdruper’s picture

Status: Needs review » Reviewed & tested by the community

Patch #12 makes available a new token: [node:page-title] , and it works fine for me.

Now you can use the Page Title configurations in the Pathauto patterns.