Even when no message is sent to drupal_set_message the pane_messages pane is outputted as an empty div:

<div class="panel-pane pane-pane-messages" >
  <div class="pane-content">

  </div>
</div>

I managed to hide it by returning null in the panels_everywhere_pane_messages_content_type_render function in pane_messages.inc (for debugging purposes):

function panels_everywhere_pane_messages_content_type_render($subtype, $conf, $panel_messagesrgs) {
  $block = new stdClass();
  $block->content = theme('pane_messages');
  return NULL;
}

I tried making the return conditional and only return if $block->content was set but it doesn't work(it still outputs an empty div):

function panels_everywhere_pane_messages_content_type_render($subtype, $conf, $panel_messagesrgs) {
  $block = new stdClass();
  $block->content = theme('pane_messages');
  return $block->content ? $block : NULL;
}

It would be nice to not clutter up the HTML code with a couple of extra divs when it's not needed..

Comments

merlinofchaos’s picture

Try giving it the "No style at all" style. You probably don't need pane markup around the messages anyway.

emattias’s picture

The problem is I'm using a 960 grid theme which requires the wrapper divs with the correct classes (which I set in the pane settings) position it correctly in the grid when the messages are displayed. Is the style the problem?

merlinofchaos’s picture

Well, no, the style isn't the problem. I had just hoped that it was an easy way around the problem. I'm not sure what the actual problem is, honestly, as I haven't run into it. Would need to look more deeply. Generally, panes don't render if the content is actually empty, though sometimes having things that are invisible (empty markup, for example) will make Panels think it's not empty and render it anyway.

It shouldn't, normally, render things that are actually empty (i.e, $content is an empty string).

Letharion’s picture

Status: Active » Closed (won't fix)

Since returning NULL solves the problem, I'm guessing that Merlins guess is correct, and the problem is that there is "empty text" in the pane. As we don't want PE to add normally needless trims to everything, I'm closing this issue.

If you can reproduce this with a truly empty pane, please re-open.

dagomar’s picture

I noticed this too, I was able to remove the behaviour by removing empty lines from the output.

jwilson3’s picture

Issue summary: View changes
Status: Closed (won't fix) » Active

There is an actual bug here. The pane messages in panels everywhere renders messages, tabs, action links, and help, if and when they are set.

However, I'm seeing a case of a page where there are no tabs, but the <div class="tabs"></div> is still being printed out, hence the div.pane-pane-messages wrapper is being displayed on the page regardless of whether there are tabs or not.

It looks like this issue is related to a change introduced a long time ago #1196710: local tasks are not rendered, where the rendering of the tabs was pushed off into the actual template, instead of in the preprocess (or process) function, like the other elements.

What happens is the line of code in pane-messages.tpl.php that checks to ensure $tabs is not empty before rendering, will never be FALSE because menu_local_tabs() returns a renderable array, hence the empty <div class="tabs"></div> is displayed. In order to know if there aren't any actual tabs to display, we can either render them and check the result *or* check the internal structure of the renderable array.

To prove this, just go to any page that doesn't have any tabs (e.g. a custom panel page).

The contents of $tabs when they are empty will be:

Array
(
    [#theme] => menu_local_tasks
    [#primary] => 
    [#secondary] => 
)

For what its worth, there is another related issue in the PE queue: #1678138: Render Action Links for Messages pane in preprocess.

If that gets in, and we can get a patch for this issue, then I think the problem of this pane randomly rendering even when it is empty will finally go away. I don't fully understand the circumstances of how the error happens in #1196710: local tasks are not rendered, but to avoid a regression, here are two options:

  1. Render the array in the preprocess. Then <?php print $tabs ?> in the template:
    function template_preprocess_pane_messages(&$vars) {
      $tabs = menu_local_tabs();
      $vars['tabs'] = render($tabs);
      //...
    }
    
    <?php if (!empty($tabs)): ?>
      <div class="tabs"><?php print $tabs; ?></div>
    <?php endif; ?>
    
  2. OR: Check the internal structure of the renderable array in the template:
    <?php if (!empty($tabs['#primary']) || !empty($tabs['#secondary'])): ?>
      <div class="tabs"><?php print render($tabs); ?></div>
    <?php endif; ?>
    
jwilson3’s picture

Version: 6.x-1.1 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new475 bytes

Here's a patch with option two, simply because its a one line change, instead of 3 lines across two files ;)

jwilson3’s picture

StatusFileSize
new477 bytes

Fixed the logic to actually work ;)

damienmckenna’s picture

Status: Needs review » Fixed

Committed. Thanks jwilson3.

  • Commit 8ee740c on 7.x-1.x authored by jwilson3, committed by DamienMcKenna:
    Issue #967690 by jwilson3: Don't output the tabs if there are none.
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.