If you have a taxonomy page (ie, taxonomy/term/1 or some alias for it), by itself it uses the taxonomy name as the title of the page. But as soon as you make a menu that points to the taxonomy page, the menu text becomes the title of the page.

The reason seems to be that there is no call to drupal_set_title($term->name); in taxonomy_term_page(). Drupal 6 *does* have this call, and in d6 the taxonomy pages always use the name of the taxonomy as the page title.

Since this is different behaviour between d6 and d7 I'm calling this a bug not a feature request. If it is a deliberate change, then call it a feature request to have it back the way it was in d6.

Files: 
CommentFileSizeAuthor
#34 1041906-term-title-36.patch683 bytesandypost
PASSED: [[SimpleTest]]: [MySQL] 36,601 pass(es).
[ View ]
#29 1041906-term-title.patch662 bytesandypost
PASSED: [[SimpleTest]]: [MySQL] 34,085 pass(es).
[ View ]
#29 1041906-term-title-d7.patch642 bytesandypost
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1041906-term-title-d7.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#25 0001-Issue-1041906-by-ELC-Use-drupal_set_title-in-taxonom-d7.patch1.68 KBELC
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 0001-Issue-1041906-by-ELC-Use-drupal_set_title-in-taxonom-d7.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#24 0001-Issue-1041906-by-ELC-Use-drupal_set_title-in-taxonom.patch1.68 KBELC
PASSED: [[SimpleTest]]: [MySQL] 33,326 pass(es).
[ View ]
#18 use_term_name_as_page_title-1041906-18.patch479 bytesbobodrone
FAILED: [[SimpleTest]]: [MySQL] 33,283 pass(es), 2 fail(s), and 0 exception(es).
[ View ]
#17 use_term_name_as_page_title.patch479 bytesbobodrone
FAILED: [[SimpleTest]]: [MySQL] 33,283 pass(es), 2 fail(s), and 0 exception(es).
[ View ]
#14 drupal-n1041906-14_d8.patch483 bytesDamienMcKenna
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch drupal-n1041906-14_d8.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#13 fix_taxonomy_term_title.patch410 bytesctibor
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch fix_taxonomy_term_title.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]
#8 1041906_get_menu_title-1.patch1.03 KBMonochrome
FAILED: [[SimpleTest]]: [MySQL] 31,496 pass(es), 20 fail(s), and 0 exception(es).
[ View ]
#4 1041906_get_menu_title.diff1.05 KBMonochrome
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1041906_get_menu_title.diff.
[ View ]

Comments

Version:7.0» 7.x-dev

Same on 7.x-dev
drupal_set_title was removed in the patch #503456: Remove multiple tid and depth handling for core taxonomy paths
It looks like an edge effect of this patch, however, is it really a bug?
I see 2 advantages :
- the title in the menu is the always the same as the title of the page
- You can "override" the name of the page to give a "more friendly" title

Its definitely a bug. You can't override the name of the page to give a "more friendly" title at all unless you write your own module to manually set the title on the page, which newbies certainly aren't going to do.

For example, what if your menu says "CATS" but you want your page to be called "My favourite pet cats"? This is currently impossible. You don't always want your taxonomy to have the same name as the menu that it appears in. If you want your taxonomy to match the menu, just change the taxonomy name to match the menu text. If you don't want them to match, you *can't*. Most people have longer titles for pages and shorter titles for menus and it shouldn't be forced on them having the same for both.

Nodes/views/etc can all have their own titles when they are linked to in a menu in d7, taxonomy pages can't. Hence, I consider it a bug.

This is definitely not by design. The issue is that taxonomy doesn't define a title callback.

StatusFileSize
new1.05 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1041906_get_menu_title.diff.
[ View ]

There appears to be multiple problems with the taxonomy titles.

The taxonomy_menu() function is definitely setting a title callback for 'taxonomy/term/%taxonomy_term' to 'taxonomy_term_title'.

This specific issue with this bug report would seem to be rather complicated. If drupal_set_title() isn't called to set a title, Drupal will call menu_get_active_title() when calling drupal_get_title(). The documentation for menu_get_active_title() plainly states it "Get the title of the current page, as determined by the active trail." The active trail being the breadcrumb, gets all of its names from menu link items, and not the menu router items. Unless the current page doesn't have a menu link item, where it will return the router item of the current page instead.

As far as I am concerned, it is a mistake for drupal_get_title() to call menu_get_active_title() as is. Instead it should call a function that properly returns the title from object returned from menu_get_item(). I have attached a patch that adds in a new function menu_get_title() that will return the title of the current page using menu_get_item() instead. I also modified drupal_get_title() to use the new function instead of menu_get_active_title().

There is a second bug however also noticed by giraffian #1049572: Taxonomy pages don't get their title set (html entities display as text) regarding html special characters being converted into entities twice. The first time the get converted is in the taxonomy title callback function taxonomy_term_title(). The second time they are getting converted is in drupal_get_title() function. As I am unsure where the correct location for this to occur is, I've left things as is.

All that said, i'd personally just change the taxonomy module to call drupal_set_title(). According to the documentation (http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/drupal...) that function is called in 64 places and there is no indication that its deprecated.

Component:taxonomy.module» menu system
Priority:Normal» Major

Found another instance of this occuring in a different module. If you create a menu link to a user profile (i.e user/1), it will change the name of the user displayed in the profile to the name of the menu link item. Menu items don't even need to enabled for the names of the pages to be changed.

This is the admin user profile on one of our sites and is an example of it occuring: http://www.hidden-waters.com/user/1

We have no modules installed except for core. Its an install of Drupal 7.0. It was done by adding a disabled menu link item to the navigation menu (not displayed) with that obviously illegal user name.

My patch in my previous post fixes this. I've changed the component to menu system, as its trivially fixed in it, and the priority as this seem to be a bigger issue than is immediately obvious.

Title:Taxonomy title is not used when a taxonomy page is in a menuMenu link title overrides page titles

Playing around a bit more I've found that the titles for admin pages can be overwritten by creating menu entries in the 'Management' menu. Some may consider this a feature, but to me it doesn't seem right. People with the ability to create menu items will be able to cause various pages to be renamed, even if they can't edit those pages, and as mentioned above the menu items don't even need to be enabled. This seems like its a security issue, albeit a rather small one.

This doesn't effect all page types of course. Any page that is generated by a module that calls drupal_set_title(), such as nodes, wont get their title changed.

I changed the issue name to reflect whats really happening.

Status:Active» Needs review

StatusFileSize
new1.03 KB
FAILED: [[SimpleTest]]: [MySQL] 31,496 pass(es), 20 fail(s), and 0 exception(es).
[ View ]

Uploading new fixed patch file with correct paths

Status:Needs review» Needs work

The last submitted patch, 1041906_get_menu_title-1.patch, failed testing.

After checking the patch failures, I'm confused about it. There is a number test of that are checking the page titles and failing because the patch is stopping Drupal from getting the title from the link menu items. One of the tests even tests the title of a user page and another of a taxonomy page that are linked in a menu, and failing even though as far as I am concerned changes made by the patch is the way it should be acting.

I can understand the search tests failing, but only just. With the patch applied the Search Content screen says "Content" and the Search Users screen says "Users" instead both saying "Search" because that is what the link menu item is labeled. Without using the menu link there is no other way to change the title of the search page.

Interestingly enough, there is even more problems with the current behaviour. If I create a new menu and put the Search menu link item in that menu, then the title of the search page becomes 'Home'. This is really really bad. Not only is the name of the page wrong, but there is no way to change it without moving Menu link item into one of the predefined menus. I would consider submitting another bug report about that, but as far as I am concerned its the same issue as this.

So the steps for that problem are
1) Create a new custom menu, or use an existing custom menu
2) Move the search menu item into the custom menu
3) Visit the search page
4) The title of the page will be 'Home' (I'm guessing its failing to create a full breadcrumb trail so cant get the name from it)

Of course it gets even better! If you put a taxonomy page in a custom menu, it grabs its name from the terms title.

So for taxonomy pages you can follow these steps
1) Create a new custom menu, or use an existing custom menu
2) Create a link to a taxonomy page (that isn't linked in other menus) in the custom menu
3) Visit the taxonomy page
4) The title will be the term title (yay!)

Alternatively you get different behaviour following these steps (the initial reported bug)
1) Create a link to a taxonomy page in one of the 'Main menu', 'Navigation' or 'User Menu' menus
2) Visit the taxonomy page
3) The title will be the name from the menu link item (grr!)

I don't think I really need to say that behaviour is seriously messed up. The lack of consistency is dreadful. Drupal 6 did not act like this.

Title:Menu link title overrides page titlesTaxonomy term menu link title overrides term page title
Version:7.x-dev» 8.x-dev
Component:menu system» taxonomy.module
Priority:Major» Normal
Issue tags:+needs backport to D7

Please just simply do what @Damien Tournoud stated earlier, drupal_set_title().

Any progress on this patch? I'm looking for a workaround for D7? I am using the View override for taxonomy term pages and the Title of each view is using the taxonomy term, even if the Title field for the View itself says "None". Right now I'm just hiding this via CSS, but a real fix would be nice.

StatusFileSize
new410 bytes
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch fix_taxonomy_term_title.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]

Ok, I created this simple patch, but considering I am a programing noob, I don't have courage to stand by it. It just works for me for now. However as I understand it needs to be modified. I don't have time to mess up with git and setting up drupal developement env now, so anyone feel free to adapt this one liner for inclusion.

--- taxonomy.pages.inc  2011-09-13 23:32:50.000000000 +0200
+++ taxonomy.pages.inc  2011-09-13 23:34:43.388610405 +0200
@@ -14,8 +14,6 @@
  *   The page content.
  */
function taxonomy_term_page($term) {
+  //Added callback to set the right title for the page.
+  drupal_set_title($term->name);
   // Build breadcrumb based on the hierarchy of the term.
   $current = (object) array(
     'tid' => $term->tid,

StatusFileSize
new483 bytes
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch drupal-n1041906-14_d8.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

The patch from #13 with a slightly better comment that adheres to coding standards (that's the only change). This patch applies cleanly to both D7 and D8.

Status:Needs work» Needs review

Status:Needs review» Needs work

The last submitted patch, fix_taxonomy_term_title.patch, failed testing.

Status:Reviewed & tested by the community» Needs review
StatusFileSize
new479 bytes
FAILED: [[SimpleTest]]: [MySQL] 33,283 pass(es), 2 fail(s), and 0 exception(es).
[ View ]

I have tried to rewrite the patch format and hope it helps. Im a bit confused with the patch formats.

StatusFileSize
new479 bytes
FAILED: [[SimpleTest]]: [MySQL] 33,283 pass(es), 2 fail(s), and 0 exception(es).
[ View ]

Renamed the patch file...

Assigned:Unassigned» bobodrone
Status:Needs work» Reviewed & tested by the community

the patch from #14 works fine with git apply and solves the problem!

I have a little bit of a core-patching-newbie-question: why should the patchfile contain "_d8" (drupal 8), doesnt the patch skip the testing phase then?
Is that common? I would like to know... :)

Status:Needs review» Needs work

The last submitted patch, use_term_name_as_page_title-1041906-18.patch, failed testing.

Status:Needs work» Reviewed & tested by the community

In case this is of interest, I am not an expert on Panels, but I have heard that this module allows page Views to be built and displayed through the use of "contexts," and that Views built in this manner are smart enough to never overwrite the URL of a taxonomy term.

The reason why the test are failing in #18 is because the Breadcrumb test asserts that the page title IS the same as the menu link title, the very reason this patch exists...
the line 1373 in modules/simpletest/tests/menu.test show:

      // @todo Normally, you'd expect $term->name as page title here.
      $this->assertBreadcrumb($link['link_path'], $trail, $link['link_title'], $tree);

It should be (I think):
      $this->assertBreadcrumb($link['link_path'], $trail, $term->name, $tree);

How do we change this? Patch for the tests first?

Status:Reviewed & tested by the community» Needs work

Coolio, let's fix and kill that @todo, please. :)

Status:Needs work» Needs review
StatusFileSize
new1.68 KB
PASSED: [[SimpleTest]]: [MySQL] 33,326 pass(es).
[ View ]

Combine the patch from #18 with the simpletest fix from #22.

Unable to get the simpletests to work locally without error, so hoping testbot does better than me!

Status:Needs review» Reviewed & tested by the community
StatusFileSize
new1.68 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 0001-Issue-1041906-by-ELC-Use-drupal_set_title-in-taxonom-d7.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Same patch applies to D7 without error or warning, but attached one based on the 7.x branch anyway.

Status:Reviewed & tested by the community» Fixed

Committed and pushed to 8.x and 7.x. Thanks!

Taxonomy should have it's own title callback, the same for forum #148145: "Forums" title is not localized

Status:Fixed» Needs review

I think that something wrong with this patch, because taxonomy already has taxonomy_term_title()
and explicit set_title is wrong

EDIT This patch should be different - we need to find the cause why the title is reverted to menu item

Priority:Normal» Major
Status:Needs review» Reviewed & tested by the community
StatusFileSize
new642 bytes
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1041906-term-title-d7.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
new662 bytes
PASSED: [[SimpleTest]]: [MySQL] 34,085 pass(es).
[ View ]

Comment of cause should be changed to the same as node_page_view()

Also this require a change notice because a lot of sites could use this "feature" which becames deprecated

Priority:Major» Normal
Status:Reviewed & tested by the community» Needs review

Please don't mark your own patch RTBC.

Also a change to an inline comment is not a major bug.

Issue tags:+menu, +taxonomy, +views, +title

I suppose this D/ / Views issue is due to this core issue, isn't it?

http://drupal.org/node/1576094

Status:Needs review» Needs work

The last submitted patch, 1041906-term-title-d7.patch, failed testing.

Status:Needs work» Needs review
Issue tags:+Quick fix
StatusFileSize
new683 bytes
PASSED: [[SimpleTest]]: [MySQL] 36,601 pass(es).
[ View ]

Quick re-roll