If Page Manager is enabled on a site, it's possible to peek in on any task's context with page_manager_get_current_page()
, so why not bring this to blocks?
When mini panels have context, they shouldn't be listed in the block admin page. However, they were appearing due to a typo. In panels_mini_block_info()
:
if (empty($panel_mini->disabled) && empty($panel_mini->requiredcontext)) {
should be:
if (empty($panel_mini->disabled) && empty($panel_mini->requiredcontexts)) {
This patch fixes that typo but continues to include those mini panels which have required contexts if page_manager is enabled.
In panels_mini_block_view()
, when page_manager is enabled, it grabs the context of the current page, matches it with the required contexts of the mini panel, and merges the contexts from the current page with any contexts from the mini panel.
It's a simple patch that does a lot! I can now make blocks that react to and extend the current page's context.
The attached mini-panel-test.txt
can be imported to mini panels for testing. It creates a mini panel that displays the body of a node when the page manager task node_view
is enabled and has a variant that outputs a page (i.e. a Panel display).
Comment | File | Size | Author |
---|---|---|---|
#1 | block_context-1621588-1.patch | 3.36 KB | Anonymous (not verified) |
mini-panel-test.txt | 1.49 KB | Anonymous (not verified) | |
panels_mini_context.patch | 1.89 KB | Anonymous (not verified) | |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedThis is more complicated patch than I originally believed. Here's the latest incarnation of it. It works... so far.
Comment #2
phayes CreditAttribution: phayes commentedThis is awesome. Thanks bangpound.
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commented| is a bitwise or, I think you want || in this one.
Otherwise this seems interesting, so I've gone ahead and committed it.
Comment #4.0
(not verified) CreditAttribution: commentedmarkdown converted to html