I set out to reproduce the problem of a mini panel being included when it's empty. I am using the most recent dev's of panels and ctools.
In my panels display I have a mini panel that has no content in it and no title.
screenshot: http://www.diigo.com/item/image/1ks4o/gqb8?size=o
export: http://pastebin.com/7ArS97wt
I add that mini panel to the panel layout and choose to override the title.
screenshot: http://www.diigo.com/item/image/1ks4o/68pq?size=o
This is the mini panel's output on the page.
<div class=?"panel-pane pane-panels-mini pane-blank-mini-panel">?<div class="panel-pane pane-panels-mini pane-blank-mini-panel">
<div class="pane-content">
<div class="panel-display panel-1col clearfix" id="mini-panel-blank_mini_panel">
<div class="panel-panel panel-col">
<div></div>
</div>
</div>
</div>
</div>
*There appears to be a missing closing div
If I choose not to override the title, this is the mini panel's output on the page.
<div class="panel-pane pane-panels-mini pane-blank-mini-panel">
<div class="pane-content">
<div class="panel-display panel-1col clearfix" id="mini-panel-blank_mini_panel">
<div class="panel-panel panel-col">
<div></div>
</div>
</div>
</div>
</div>
REF: #400332: Hide mini panels when empty
REF: #1367154: Empty mini-panels does not hide when title being overridden.
Comment | File | Size | Author |
---|---|---|---|
#21 | 1391450-21-hide-empty-mini-panel.patch | 2.66 KB | Michelle |
#19 | interdiff.txt | 1.29 KB | Angry Dan |
#19 | 1391450-19-hide-empty-mini-panel.patch | 2.66 KB | Angry Dan |
#16 | 1391450-16-hide-empty-mini-panel.patch | 2.33 KB | jwilson3 |
#14 | 1391450-14-hide-empty-mini-panel.patch | 2.96 KB | zhangtaihao |
Comments
Comment #0.0
bryancasler CreditAttribution: bryancasler commentedAdding info
Comment #0.1
bryancasler CreditAttribution: bryancasler commentedfix
Comment #0.2
bryancasler CreditAttribution: bryancasler commentedfix
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedReally you just duplicated an issue that you referenced, and my response is here: http://drupal.org/node/400332#comment-2219542
I could type it again, but that doesn't serve anybody's interests.
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedI take it back, it does serve:
Panel layouts are not smart enough to hide if there are no visible panes. It's not part of the layout system to do that. Unless a specific layout were to be smart enough to do that (it's possible with a preprocess), that is.
Comment #3
bryancasler CreditAttribution: bryancasler commentedThanks for responding Merlin. I opened up a new issue because of Letharion's comment in #26 "@R.hendel Thanks for clearly describing the problem. Again, this issue contains to many loose ends. New issue based on #23 here: #1367154: Empty mini-panels does not hide when title being overridden.. Closing this one, hoping I can get rid of it."
I was a bit confused about why it was closed if there were still "many loose ends" but I figured Letharion wanted to split the issue off into more targeted discussions.
I remembered the comment your referencing, but you later re-opened the issue and followed it up with "Re-opening. With the new render pipeline, I think this is much more possible now. We could slide a check into panels_renderer_standard::render_layout() and set a flag on the display (or renderer) to abort the rendering if there is no rendered content at all." So I figured that this was indeed possible and I was hoping to help in any way I could.
Comment #4
merlinofchaos CreditAttribution: merlinofchaos commentedHm. I had forgotten saying that.
In that case, not a bug, but a feature request.
Comment #5
Letharion CreditAttribution: Letharion commentedIn response to #3, yeah, I just wanted to close an issue that had no clear instructions for how to reproduce the error, and probably contained several different errors in itself. More targeted was indeed the goal, like this one :)
@merlinofchaos, that missing
</div>
does look like a bug, though, right?Comment #6
rich.yumul CreditAttribution: rich.yumul commentedTo get around this issue in the 6.x space, I created a template override in my site's custom theme, that overrode the onecol layout (my mini-panel was using the one column layout). Basically, I just put 'panels-onecol.tpl.php' in my theme folder and it looked like this:
Of course, you have to make sure the views are returning nothing first though. HTH, YMMV. :)
Comment #7
osopolarI am using the woraround too, but would prefer to have an option "hide when empty" ... like views has.
Comment #8
zhangtaihao CreditAttribution: zhangtaihao commentedHere's my attempt at hiding empty mini panels.
The point, I believe, is to not return any content for a mini panel CTools block if its content is empty after rendering. Then, in the renderer, the layout is only rendered if any region is not empty. Otherwise, the render does not trigger the layout (e.g. one column) and therefore does not return any markup, and the mini panel does not show up.
Core blocks seem to also hide a mini panel if block content invoked from
hook_block_view()
is empty.Is this the right approach?
P.S. I didn't use
$this->rendered['panes']
in the renderer to check for content because an editor renders regions with no panes (to output a UI for adding panes).Comment #9
zhangtaihao CreditAttribution: zhangtaihao commentedOops.
Comment #10
anniegreens CreditAttribution: anniegreens commentedI have applied the patch in #8 and it appears to be working for my scenario: panel page with mini panel containing a title and three views panes displays. When all three views return no results based on contextual filters the mini panel no longer appears.
Comment #11
bbinkovitz CreditAttribution: bbinkovitz commentedI applied the patch and it effectively hid the empty minipanel I tested it with. It didn't affect populated minipanels.
Comment #12
merlinofchaos CreditAttribution: merlinofchaos commentedThis needs to be optional. Let's say I have a panel page, and for some reason, the panel has no content. It returns blank, which will ultimately cause a whitescreen rather than an empty page. Plus, we'll spend extra cycles testing for empty panels when we don't need to.
I think mini panels could set a flag on the renderer or something and that flag could be checked prior to running this test.
Comment #13
jantoine CreditAttribution: jantoine commentedUpdated patch in #8 against the latest dev.
Comment #14
zhangtaihao CreditAttribution: zhangtaihao commentedSorry this took me a while to get back to.
Updated patch per #12. This works based on the (possibly tricky) assumption that a mini panel is rendered by loading the exportable object via the Export API and contains the
table
attribute. I found implementinghook_panels_pre_render()
the only practical way (without adding the flag to display) to set the flag on the renderer only after a display has initialized the renderer object.Comment #15
jwilson3Re: #14, Good start, but being able to set the show_empty_layout flag through the Mini-panels Admin UI would be a basic requirement for this feature to be of any general use.
Also, I wasnt able to get this to apply to 7.x-3.x-dev had to apply by hand.
Comment #16
jwilson3Re-rolled #14 to apply against latest 7.x-3.x-dev, I still havent implemented an admin settings form for this (per #15), so am leaving in needs work.
Comment #16.0
jwilson3fix
Comment #17
freeform.steph CreditAttribution: freeform.steph commentedThank you for this, I successfully applied it to the latest dev release without issue.
Comment #18
ShaunDychko CreditAttribution: ShaunDychko commented#16 is great. Thank you very much!
Comment #19
Angry Dan CreditAttribution: Angry Dan commentedThis patch wasn't working for me for blocks rendered via mini_panels_block_view because the owner reference wasn't being set. I'm not sure if this is correct, but I've modified mini_panels_block_view to include the owner value on the display. Patch rolled against latest stable release.
Comment #21
MichelleThere was an offset when I applied the patch in #19 to the latest dev so I uploaded a new patch just to fix that; I made no other changes to it.
I tested it and it does hide the mini-panel when it's empty. I don't know what "rendered via mini_panels_block_view " means so I wasn't able to test the issue in #19.
My one concern is that in #12 merlinofchaos said it should be optional. #14 says it addresses #12 but I don't see any setting that makes it optional.
Comment #22
Angry Dan CreditAttribution: Angry Dan commented@michelle, I was probably referrring to the point in my debugging that I had the problem, but given it's a hook implementation of hook_block_view(), mini_panels_block_view() must be my poor code for "mini panels added via the blocks administration page"
Comment #23
MichelleAh, I see. Ok, I just tested a mini panel added as a block and patch #21 worked to hide it there as well. I think this is RTBC but someone else needs to set it since technically I had the last patch even though it was just a minor re-roll.
Comment #24
tlangston CreditAttribution: tlangston commented#21 solved the issue for me here as well.
Comment #25
potassiumchloride CreditAttribution: potassiumchloride commented#21 appears to have solved the issue for me as well. This has saved a major headache. Thank you!
Comment #26
hey_germano#21 solved the issue for me, too. Thanks!
Comment #29
annya CreditAttribution: annya commented#21 works like a charm
Comment #30
japerryI think this is good to go, if we missed something we can file another bug report.
Comment #33
japerrySo it does appear like there is a bug from this. Will be fixed in #2787113: Update to 3.6 causes mini panels saved in code to be deleted