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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

devuo’s picture

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

merlinofchaos’s picture

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

The information you seek is already available in page_manager_get_current_page()

devuo’s picture

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.

merlinofchaos’s picture

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.

merlinofchaos’s picture

Status: Needs work » Needs review
FileSize
1.41 KB

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

devuo’s picture

Thanks Merlin, I will give feedback tomorrow.

devuo’s picture

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!

merlinofchaos’s picture

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.

merlinofchaos’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed.

Status: Fixed » Closed (fixed)

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