Currently we only have the possibility to get currently being rendered display, but not the handler. This can be a problem, because there's no simple way to get the handler settings of the handler for example at a content-type plugin render time. This necessity arised while overriding the 'render callback' of 'page_breadcrumb' content-type with the implementation of breadcrumbs in Panels Breadcrumbs. Since 'Panels Breadcrumbs' configuration lies at the handler and there's no access to the handler object at content-type render time, it's impossible to generate a breadcrumb based on user preferences.

Files: 
CommentFileSizeAuthor
#5 1418598-move-page-manager-set-current-page.patch1.41 KBmerlinofchaos
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1418598-move-page-manager-set-current-page.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
panels-panels_get_current_page_handler.patch1.08 KBdevuo
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch panels-panels_get_current_page_handler.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Comments

See #5 in #1398244: Support the breadcrumb pane for the given example at work.

Status:Needs review» Closed (won't fix)

The information you seek is already available in page_manager_get_current_page()

Status:Closed (won't fix)» Active

The problem merlin, is that the static variable in page_manager_get_current_page() is only set after the content pane has been rendered, and not before.

I was fully aware of the existence of this function, and I didn't reference it in the issue because page_manager_get_current_page() isn't meant to get the just handler, but the whole page (task, subtask, handler, etc.), and it only gets set, as I said, after the page has been rendered.

The whole magic happens in ctools_context_handler_render_handler():

  1. Line 103: panels_panel_context_render() is called.
  2. Line 129: page_manager_get_current_page() is set for the first time.

My point is that, the handler is thrown around for quite awhile in the code, even before the display itself is set through panels_get_current_page_display(), and I believe there's no harm done to let developers have access to the handler before page_manager_get_current_page() is set, in order leverage that information at content pane render time.

Status:Active» Needs work

My issue with this is that Panels isn't responsible for the Page, so this function is a cross responsibility DX fault. Page Manager is responsible for the page. That means what we really need to do is somehow fix the ordering.

I'd be interested if seeing if moving page_manager_get_current_page() earlier would cause any problems. I don't see that it should do so, and it would be far better than adding another WTF function, IMO.

Status:Needs work» Needs review
StatusFileSize
new1.41 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1418598-move-page-manager-set-current-page.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Here's a patch. Can someone verify if this works or not?

Thanks Merlin, I will give feedback tomorrow.

Title:Add panels_get_current_page_handler()Set page_manager_get_current_page() before the page render
Status:Needs review» Reviewed & tested by the community

I've tested it, and as far as I could tell everything that previously worked, still works!

Project:Panels» Chaos tool suite (ctools)
Version:7.x-3.x-dev» 7.x-1.x-dev
Component:Plugins - display renderers» Code

Moving to the CTools queue.

Status:Reviewed & tested by the community» Fixed

Committed and pushed.

Status:Fixed» Closed (fixed)

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