There's a challenging limitation when using Panels IPE. Many panes render contents based on the current path, which is incorrect when rendering a pane after a Panels IPE action such as adding a pane, updating a pane, or saving IPE.
There are several related issues about this, but I'm starting a new one with a focused approach to work around this limitation.
The basic idea is that when the display is initially rendered with Panels IPE, we should store the current path information in a session variable. Then when later rendering pane content, we can fake $_GET with the path in the session, and finally restore the path after rendering.
Comments
Comment #2
joelstein CreditAttribution: joelstein as a volunteer commentedHere's a simple patch which works wonders.
Comment #3
joelstein CreditAttribution: joelstein as a volunteer commentedUpdated patch to apply cleanly with new Panels release.
A great test case to see this in action is with a Menu Block pane, which if often used to render menu items in a sidebar based on the active menu trail of the current path.
Comment #4
attiks CreditAttribution: attiks at Attiks commentedThanks!!!
Comment #5
joelstein CreditAttribution: joelstein as a volunteer commentedHere is an improved patch which fakes the path during the entire render phase, not just when the panes are rendered, in case it's needed in any of the Panels render hooks.
Comment #6
joelstein CreditAttribution: joelstein as a volunteer commentedOk, the last patch couldn't work since meta() is called within render(). This moves the fake path business to render_layout(), which is still better than render_pane_content().
Comment #7
stefan.kornI can confirm this is working and I have discovered no "side effects" so far.
So +1 for bringing this patch in.
Comment #8
brenda003Patch in #6 works great, this was a big problem for us on OG pages not showing all content upon IPE save.
Comment #9
berliner CreditAttribution: berliner commentedI am not entirely sure that I like this approach, but I can confirm too that it is working as advertised. The patch applies properly to Panels 3.9.
Comment #10
stefan.kornPatch from #6 might not work if there are broken images in the content that is being rendered within IPE panes (surely, there should be no broken images on a website, but hey this is my not so perfect world ..). This seems to be because the broken image creates an additonal page request and this request might deliver the "fake path", which then does not have the right context for the rendering.
I made an addition to the patch from #6, which tries to directly get a node context from the ajax path and use this as fake path instead of the fake path given with #6. If no node path can be extracted from the ajax path, the faking from #6 will still work as before.
This additional patch will only affect a very specific path, like /panels/ajax/ipe/save_form/panelizer:...
This might surely be improvable, but it does satisfy my current needs.
I am providing the patch (and interdiff with #6) in case someone experiences a similar problem.
Comment #11
xlin CreditAttribution: xlin as a volunteer commentedUpdate patch from #6 to take into account that user might not have panelizer access to all content types on the site. E.g If user go from node that they can panelizer to a node they can't panelilzer, it will have the wrong context because the
$_SESSION['panels_ipe_fake_path']
is still there.