Currently, title callbacks are used in at least three other contexts besides page titles -- menu links, contextual links, and local tasks. However, there is no way to return different titles for any of these situations.
I'd like to introduce a feature allowing access/title callbacks to take a '%context' argument, having a value of 'page', 'link', 'contextual link', 'local task', and NULL if the context is ambiguous, such as when menu_get_item() is used on an arbitrary path. user_page_title() then could determine whether it should return 'My account' based on $account->uid == $user->uid && $context == 'link'.
I could also see this being useful in other cases, such as reducing UI clutter. A context-aware title callback could keep the title short for local tasks or contextual links, while rendering a longer title in a page context.
| Comment | File | Size | Author |
|---|---|---|---|
| menu-callback-context.patch | 7.02 KB | carlos8f |
Comments
Comment #1
sunWe already have (most of) the required constants for this:
MENU_CONTEXT_NONE
MENU_CONTEXT_PAGE
MENU_CONTEXT_INLINE
Apparently, no context love for links in menu trees yet. ;)
I'm on crack. Are you, too?
Comment #2
damien tournoud commentedThat's a no go for Drupal 7 at this point. Let's discuss for Drupal 8.
Comment #3
klausidoes not apply anymore.
Comment #4
carlos8f commentedComment #8
klausiDrupal has split up routing and menus, so I think this is no longer relevant. Feel free to reopen!