The title is set on node/NID pages by the menu entry for the node module. Later on node_page_view does it as well which is "confusing" and crufty. This patch removes the duplicated unnecessary drupal_set_title.

Looking at all of contrib for 6.x there are only three modules which actually call node_page_view directly. When those are upgraded to 7.x if they were relying on the drupal_set_title in node_page_view then they can be updated.

Comments

greggles’s picture

We could get even more direct with this.

I guess that this would need some documentation on the update modules page to describe the change. Proposed text:

node_page_view has been removed. Instead you should now use node_view. Also, node_page_view used to set the title but it no longer does. So, you may want to call drupal_set_title yourself.

Status: Needs review » Needs work

The last submitted patch failed testing.

pwolanin’s picture

this is failing testin for good reason - we have a feature in the menu system since D6 that the page title may be set by a menu link title, if a menu link exists for the current page.

So - on these pages in the test, the page title does not match the node title.

this is a deliberate feature we added in D6 - the drupal_set_title() could be seen as a way to bypass this feature. An alternative would be to automagically always or usually set the link title to match the node title.g

Tor Arne Thune’s picture

Version: 7.x-dev » 8.x-dev

This is commented in the code now:

...
// The page callback also invokes drupal_set_title() in case
// the menu router's title is overridden by a menu link.
'page callback' => 'node_page_view',
'page arguments' => array(1),
...
function node_page_view($node) {
// If there is a menu link to this node, the link becomes the last part
// of the active trail, and the link name becomes the page title.
// Thus, we must explicitly set the page title to be the node title.
drupal_set_title($node->title);
...
vomitHatSteve’s picture

I'm sorry. I don't see why this behavior is desirable. If a contrib. module explicitly declares a path that matches a node's implicit path, shouldn't the contrib. title take precedence?

This also results in other undesirable behavior. What if the title is modified in hook_init, hook_boot, or some other early processing function? It will be overwritten again by this node_page_view.

greggles’s picture

Status: Needs work » Closed (works as designed)

Seems like this is the right status then?