I have a view inside a panel (node-panel).

The layout of my panel is handled in my-panel-layout.tlp.php.

Now when my view is empty It's title and fields are no longer displayed. I would still like the pane to display the view's title and the views field in the same way they are rendered when the view is not empty. To this effect, I have copied the produced html of non-empty view and included it in my-panel-layout.tlp.php.

It works but now I need a test for my tpl.php file to decide to display this hmtl when the view is emty. Something like:

 <?php   if( /*empty($myView)*/  ) : ?>

     /* my default html here */    

    <?php else : ?>

     <?php  print $content['left']; ?>

 <?php endif; ?>

The problem is that in my tpl.php file I do not have access to a variable that would tell me if myview is empty. I cannot use empty($content['left']) because I have other elements in that left pane that get returned even when my view is empty so $content['left'] is never empty. Besides $content['left'] is already rendered.

How can I provide my tpl.php access to a variable that would let me test if my view was empty? Is there a preprocess function I could call?

  • You already asked the same question yesterday. Please don't post the same question multiple times, instead edit your first question if you want to add more information.
    – Elin Y.
    Commented Nov 18, 2013 at 6:07
  • possible duplicate of Displaying title of an empty view
    – Elin Y.
    Commented Nov 18, 2013 at 6:09
  • I have seen admins strongly demand that multipart questions be divided into separate questions. OP here has done exactly that. Commented Nov 18, 2013 at 7:30
  • @ЕлинЙ. These questions are similar and related, but as far as I read them they are not duplicates. "Displaying title" and "determining if empty" are perfectly separate tasks, even if most difficult part of the task happens to be common between them.
    – Mołot
    Commented Nov 18, 2013 at 13:16
  • 2
    Ok, I am agreed that this question is not a duplicate of the other one. @Baba, sorry for the inconvenience.
    – Elin Y.
    Commented Nov 18, 2013 at 13:50


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.