Posted by animelion on January 2, 2012 at 2:08am
17 followers
| Project: | Panels |
| Version: | 7.x-3.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Issue Summary
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.
Comments
#1
Really 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.
#2
I 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.
#3
Thanks 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.
#4
Hm. I had forgotten saying that.
In that case, not a bug, but a feature request.
#5
In 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 does look like a bug, though, right?
#6
To 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:
/*** @file
* Template for a 3 column panel layout.
*
* This template provides a very simple "one column" panel display layout.
*
* Variables:
* - $id: An optional CSS id to use for the layout.
* - $content: An array of content, each item in the array is keyed to one
* panel of the layout. This layout supports the following sections:
* $content['middle']: The only panel in the layout.
*/
if ($content['middle']):
?>
<div class="panel-display panel-1col clear-block" <?php if (!empty($css_id)) { print "id=\"$css_id\""; } ?>>
<div class="panel-panel panel-col">
<div><?php print $content['middle']; ?></div>
</div>
</div>
<?php endif; ?>
Of course, you have to make sure the views are returning nothing first though. HTH, YMMV. :)
#7
I am using the woraround too, but would prefer to have an option "hide when empty" ... like views has.
#8
Here'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).#9
Oops.
#10
I 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.
#11
I applied the patch and it effectively hid the empty minipanel I tested it with. It didn't affect populated minipanels.
#12
This 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.
#13
Updated patch in #8 against the latest dev.