- Add a menu position rule:
- Administrative title: User profiles
- Show content types: None selected
- Show pages: "users/*"
- Menu item: A random menu item under 'Main menu'
- Visit user/1
- Observe instead of your user name being displayed, you get "User profiles (menu position rule)" as the page title.

The problem is that menu_get_active_title() returns the fake menu item.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JohnAlbin’s picture

Title: Missing page titles » Wrong page titles displayed

*sigh* You're right.

The core patch at #520106: Allow setting the active menu trail for dynamically-generated menu paths. has extensive tests to make sure that setting a different active trail won't affect the page title. Once that's committed, I'll be able to convert this module to use the simpler menu_tree_set_path() instead of the hacky cache_set method I'm using now.

In the mean time, I'll have to contemplate how best this could be fixed. Maybe altering the menu item at the end of the trail to have the same title as the actual page? Or simply menu_set_breadcrumb()? Not sure.

JohnAlbin’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

gaele’s picture

Status: Closed (fixed) » Active

This is either not yet fixed, or it reappeared.
On my user pages the page title shows the parent menu item instead of the user name.

gaele’s picture

This bug notwithstanding: thank you for this excellent module, John! It's just what I needed.

JohnAlbin’s picture

Title: Wrong page titles displayed » Wrong page title displayed when using non-default options on settings page

This only happens when the setting at admin/structure/menu-position/settings is not set to "insert the current page's title into the menu tree".

tomwrobel’s picture

I'm not seeing this problem for nodes.

Howver, having applied the patch at: Add support for menu position rules to be triggered on taxonomy terms pages it is affecting taxonomy term pages.

The workaround so far is to set the page title explicitly in the 'parent' case in menu_position_translated_menu_link_alter, but this feels hackish...any suggestions greatly appreciated.

nils.destoop’s picture

I'm having this also. Even when the setting is set to 'parent'.

When i disable following lines, the title is not beïng replaced:

  if ($set_breadcrumb) {
    // Manually set the preferred link for this path so that
    // menu_get_active_trail() returns the proper trail.
    $preferred_links = &drupal_static('menu_link_get_preferred');
    $preferred_links[$_GET['q']][MENU_PREFERRED_LINK] = menu_link_get_preferred($menu_item['link_path']);

    // Remove the menu position router from the end of the trail.
    $active_trail = menu_set_active_trail();
    array_pop($active_trail);
    menu_set_active_trail($active_trail);
  }

Ofcourse this is not a fix ;).

Daniel Wentsch’s picture

Issue summary: View changes

Confirming #8.
I'm having the issue with Basic Cart's (https://drupal.org/project/basic_cart) Cart page. No matter which menu position setting I choose, the page title of the cart gets overridden with the Menu parent title.

Any ideas?

PS:
For now I worked around the issue by implementing template_preprocess_page and (re-)setting the title there:

/*
 * Implements template_preprocess_page()
 */
function MYTHEME_preprocess_page(&$vars) {
/*
 * Override Page Title for Shopping Cart
 * (because Menu Position killed it: https://www.drupal.org/node/993958#comment-9606031)
 */
  if(arg(0) == 'cart') {
    drupal_set_title(t('Your shopping cart'));
  }
}
gaele’s picture

From #1898092: Menu Position Rule link shows up in main menu: "I disabled the menu position rule, cleared caches, and re-enabled it"
This solved the problem for me.

fionamccaskill’s picture

Version: 7.x-1.x-dev » 7.x-1.1

This issue is happening for me but I'm using version menu_position-7.x-1.1

Disabled menu position rule and cleared caches and re-enable it didn't fix the issue

BarisW’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Active » Closed (cannot reproduce)

This must have been fixed in between 1.1 and dev, because I can't reproduce it anymore.
Please re-open if this is still an issue in 1.x-dev.

BarisW’s picture

Status: Closed (cannot reproduce) » Needs review
FileSize
858 bytes

Re-opening as I now see this happening. What about this? Would this work?

jfrederick’s picture

The patch in #13 fixed the page title for me, but it unfortunately also removed any parent breadcrumbs to the current page.

To fix this, I ended up not applying the above patch, and instead selecting the menu_position setting 'Insert the current page's title into the menu tree.', which I did not have to do previously.

FWIW, upgrading to ctools 7.x-1.8 broke this for me. Considering that, this issue might be related to #1369852: Page Manager displays menu title instead of node title.

brunodbo’s picture

The patch in #13 fixed this issue for me, though I was having trouble with some characters in titles getting displayed as HTML entities. I'm guessing this is due to the title is getting run through check_plain() twice, once in the drupal_get_title(), and a second time in drupal_set_title(). Does that make sense?

Attached patch sets the PASS_THROUGH parameter in drupal_set_title(), preventing the title from going through check_plain() twice.

joelstein’s picture

In case anyone else is using Page Manager / Panelizer, make sure the title is set to %node:title. That ended up being the culprit for me.

See #1369852-15: Page Manager displays menu title instead of node title.

pstewart’s picture

Upvote for patch from #16 - fixes the problem for me perfectly, including correct handling of html entities due to the PASS_THROUGH parameter.

  • BarisW committed 27f72b1 on 7.x-1.x
    Issue #993958 by BarisW, brunodbo, gaele, JohnAlbin, tomwrobel,...
BarisW’s picture

Status: Needs review » Fixed

Thanks all. Committed to 7.x-1.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.