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.
Comment | File | Size | Author |
---|---|---|---|
#5 | 1418598-move-page-manager-set-current-page.patch | 1.41 KB | merlinofchaos |
panels-panels_get_current_page_handler.patch | 1.08 KB | devuo |
Comments
Comment #1
devuo CreditAttribution: devuo commentedSee #5 in #1398244: Support the breadcrumb pane for the given example at work.
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedThe information you seek is already available in
page_manager_get_current_page()
Comment #3
devuo CreditAttribution: devuo commentedThe 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()
:panels_panel_context_render()
is called.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 beforepage_manager_get_current_page()
is set, in order leverage that information at content pane render time.Comment #4
merlinofchaos CreditAttribution: merlinofchaos commentedMy 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.
Comment #5
merlinofchaos CreditAttribution: merlinofchaos commentedHere's a patch. Can someone verify if this works or not?
Comment #6
devuo CreditAttribution: devuo commentedThanks Merlin, I will give feedback tomorrow.
Comment #7
devuo CreditAttribution: devuo commentedI've tested it, and as far as I could tell everything that previously worked, still works!
Comment #8
merlinofchaos CreditAttribution: merlinofchaos commentedMoving to the CTools queue.
Comment #9
merlinofchaos CreditAttribution: merlinofchaos commentedCommitted and pushed.