Download & Extend

"default settings" override node specific settings

Project:Page Title
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (works as designed)

Issue Summary

in the "default settings" page /admin/content/page_title
I place a value in the field for "Pattern for Page".
I then go to any node of type "Page" and see the title I entered - great!

Then I edit one of the nodes and in the "Page title:" field I enter some other text.
I go to view the page and the title remains the same as the one I entered in "default settings - pattern for Page".
Only when I remove what I entered in "Pattern for Page" does the text I entered in "Page title" appear.

Comments

#1

Component:Code» User interface
Category:bug report» support request
Priority:normal» minor
Status:active» postponed (maintainer needs more info)

What did you put in the Pattern For Page? Did it contain [page-title] or [title]?

#2

Version:6.x-2.0» 6.x-2.x-dev
Component:User interface» Code
Category:support request» bug report
Priority:minor» normal
Status:postponed (maintainer needs more info)» needs review

I'm not sure if this is a bug or by design, but the behavior I expect here would be for page titles set at the individual node level to override the defaults set in the admin settings. Currently this does not happen if there is a default set for a particular node type. The issue occurs in the page_title_page_get_title() function. The attached patch against 6.x-2.x-dev is an attempt to fix this.

Note: This patch is only for the "node" scope within the aforementioned function as I do not have occasion to test the other scopes at the moment. I assume patching the other scopes would be as trivial as this patch. I can look into this when I have time but that won't be for at least a couple of weeks.

AttachmentSize
page_title_override.patch 839 bytes

#3

Status:needs review» closed (works as designed)

There are two parts to Page Title.

  1. The pattern. Page title will try to get a pattern for a specific node type (or term's vocab, etc.). If it cannot find one, it will fall back to the value in the default box. This technique allows one general pattern (the default) and the ability to override this default pattern on a per node-type basis (or per term-vocab.. depending on the scope).
  2. The Page Title. Page Title will try to load an overriding Page Title value on a per "object" basis. If the scope appears to be a node, it will try to get the overriding Page Title for that node. If there is no overriding Page Title value for the scope, then it will use the Node's title instead. This is why it is important to configure your patterns properly. If you configure your per node-type pattern to just use [title], then you will not be able to override using the Page Title field as the Token module will only be looking at the Node Title. You *must* use the [page-title] token if you want the ability to override. This is a special token provided by the Page Title module which will use the value of the Page Title field (if specified) but fall back to just the object title if no overriding value is available.

I hope this provides some clarity.

#4

I think the original poster is trying to do the same thing as I'd like to do. Essentially I've got a node type where the default value is :

[title] | [site-name]

but in the case where I've put in a page title for a specific node, I want it to completely override the entire title for that node. In other words not include the site name at all.

The problem is that if I swap the [title] above for [page-title], then there is still no way to not show the " | [site-name]" part unless I manually add it to every node.

Is it possible to have an option where you can let the individual node page titles completely override the defaults for that node type? Make sense?

Thanks,
Nick

#5

I think the behavior of Page Title should let you specify replacement patterns per content type, and use them, -only- if a user provided title does not exist for the node. That is how pathauto works. Imagine if Pathauto let you give a custom URL then said 'ummm no heres one based on default pattern for Page' instead.

It looks like if a pattern is specified for a content type, and you put in a custom title for a node, it uses the default pattern anyway.

It seems like an easy fix to check the Page Title field when processing the form submission to know to either use what the user provided, or use the default page title setting(s).

#6

Status:closed (works as designed)» active

Would also love to see this change commited.

#7

Status:active» closed (works as designed)

The above is either:
1) A misunderstanding about the different between a Page Title and a Page Title Pattern (one is a value to be inserted into the other)
or
2) A Feature Request to allow Tokens in the Page Title field on a per-node basis. This would be possibly but I'd prefer to manage that in a separate task (to remove "noise").

There is also the possibility this task is about providing a default value for the Page Title field. I'm not sure why you'd EVER want that as it increases the chance of a duplicate Page Title. Besides, the [page-title] token will inherit the Node Title if no Page Title value is found on the node.

#8

I needed the page title to work like:

1) if page title is provided, use that "as is" (don't use default pattern)

2) if not provided, use the pattern

So, used the hook_page_title_pattern_alter like:

function mymodule_page_title_pattern_alter(&$page_title_pattern, &$types) {
  if (arg(0) == 'node' && is_numeric(arg(1))) {
    $node = node_load(arg(1));
    if ($node->page_title) {
      $page_title_pattern = '[page-title]'; // only use page title not default pattern
    }
  }
}

It works great.

#9

Replying to comment #4 - "but in the case where I've put in a page title for a specific node, I want it to completely override the entire title for that node. In other words not include the site name at all."

I had the same issue, but found a simple fix provided here: http://drupal.org/node/389838 . I added this code to my theme's template.php and it works.