Following scenario:

I have 2 Panel pages 'node/%node' and 'node/%node/edit'.
So I see 2 tabs ('View' and 'Edit').

What I want is modifing (e.g tokenize) the titles of the 2 displayed tabs by using some context information about the node object, e.g. 'NODE_TITLE-View', 'NODE_TITLE-Edit'.

As far as I can see Page Manager doesn't "hijack" the 'title callback' via hook_menu_alter(), right? I see (the default title callback) 'node_page_title' as 'title callback' in my example above. I think this is the point to start. We can pass a loaded object (e.g. a node object in my example scenario) into the title callback by utilizing 'title arguments'.

I can support development of this feature because I think it would be useful for other Page Manager or Panels users as well.
But I am looking for some hints where to start.

Thanks in advance,
Martin

Comments

m_z’s picture

I try to create some "pictures" to describe my problem.

Here is what you get at the moment. There are 2 Tabs from my Page Manager/Panels pages.

.---------------. .---------------.
|   Tab1        | |   Tab2        |
'---------------' '---------------'
MyNodeTitle
...

But I want to get my node title text inside both tabs:

.--------------------------. .--------------------------.
|   Tab1 MyNodeTitle       | |   Tab2 MyNodeTitle       |
'--------------------------' '--------------------------'
MyNodeTitle
...

To make it clear: I want to "inject" some context tokens from my Panels arguments inside the menu item titles.

.--------------------------. .--------------------------.
|   Tab1 %node:title       | |   Tab2 %node:title       |
'--------------------------' '--------------------------'
MyNodeTitle
...

And it would be nice to do this via Page Manger / Panels UI, wouldn't it?

Somebody out there?

merlinofchaos’s picture

Currently this is not possible.

It's something that could theoretically be added, because in Drupal 6 the menu titles can have callbacks. However it could come with a significant performance hit to use it. And it will take a reasonable amount of developer time to do.

If you want a way to do it now, you would have to be pretty familiar with the Drupal APIs. You could use hook_menu_alter() to add a title callback to the menu item and figure out the title from the data provided.

m_z’s picture

@merlinofchaos:

Thank you for your reply.

I am familiar with hook_menu_alter() and title callbacks. But I know, that you have some more insights into Page Manager and the way it deals with its context ;-)

What I want to prevent is to get my node title via an additional node_load($node_id_from_path_argument) call.
In Page Manager we already have this information stored in the context of that page (e.g. %node:title).

Maybe we can extend the menu settings page of Page Manager UI in the following way (admin/build/pages/nojs/operation/page-MY_PANELS_PAGE/settings/menu):
- Put a checkbox 'Use context tokens in the title of this menu item.' below the Title textfield (default value is unchecked).
- If checked, then the user will see a list with all available context tokens (like the list that we see under Variants > Context) which can be used in Title textfield.
- Only if checked, Page Manager's "hook_menu_alter() magic" will inject its own title callback (together with the title arguments for our context tokens) which will do the token replacement at run time.

@merlinofchaos: What do you think about the proposed design? Would you include it in a future release?

Using this design everything keeps like it is for everybody who doesn't check the additional checkbox (= your point with performance). Only guys who need this feature will pay the performance costs.

Like I said before: I don't know if this feature is of common interest and I am not deep enough in Page Manager code to solve this issue on-the-fly, but I can support development of this feature.

Are there some helping hands out there?

sdboyer’s picture

The architecture you describe would only help for the custom page task handler - not for any of the path-literal system task handlers. Each of those would have to add their own system for overriding the title callback at the path they normally occupy - not impossible, but not insignificant either.

@merlinofchaos - I don't see why the performance impact of this would be so significant? Pretty straightforward to override the menu callback, and we could probably do more goodness with menu loader functions to get it the context data it needs. Doesn't seem like it should be TOO bad...

Unfortunately, I don't have the bandwidth to work on this in my spare time.

m_z’s picture

@sdboyer: Yes, you are right - for system tasks (like node_view) it would be nice to have a "Settings" > "Menu" option below "Summary" in Page Manager UI.

But maybe we start with a solution for the custom page task handler?

@sdboyer / merlinofchaos / "friendly-Views-guru":
Can you give me some information which .inc files (and maybe which functions) must be modified to achive my proposed architecture (#3)? To add a checkbox to UI is easy, but it would save a lot of time if somebody could tell me ...

1. ... how menu settings are stored?
2. ... where do I find the context substition tokens?
3. ... where does Page Manager's "hook_menu_alter() magic" take place?

Thanks in advance.

r-dent’s picture

I would be very happy for such a feature. I´m currently trying to build such functionality by myself. But i had not really produced a usable solution right now.

I would be thankful if somebody could post some information about the questions M_Z postet above. Maybe this would be a good starting point.

merlinofchaos’s picture

The title callbacks are called a lot more often than the page callbacks themselves, similar to the issues with access callbacks. So you could run the callback fairly often.

Look in page_manager/plugins/tasks -- All of the 'System' tasks have a file there that describes them. They use a menu alter hook to do their magic. However, they don't have any extra storage, so adding settings generally means adding variable_set() and variable_get() calls.

m_z’s picture

@merlinofchaos:

Thank you for your reply which helped me a lot.

There is only one open question from my #5 posting:

2. ... where do I find the context substition tokens?

Maybe someone can help me with this question, because afterwards I can start creating a patch.

merlinofchaos’s picture

If you have the contexts already, then see ctools_context_keyword_substitute() in context.inc for performing the actual substitutions. It should be straightforward.

japerry’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Closing this issue as outdated as Drupal 6 ctools is not supported. If this issue is relevant for Drupal 7, feel free to re-open and mark for Drupal 7 (or 8)