0

In Drupal 7, is there a way to set a default, universal No results message for Views? Which of these following options should work?

enter image description here

Should I use a Rendered Entity? If so can I create a node (say, called 'no-results')? Is the Entity Id field, the URL of the entity?

1 Answer 1

1

You can copy views-view.tpl.php template to your theme folder, then modify relevant part.

<?php if ($rows): ?>
  <div class="view-content">
    <?php print $rows; ?>
  </div>
<?php elseif ($empty): ?>
  <div class="view-empty">
    <?php print $empty; ?>
  </div>
<?php endif; ?>

To:

<?php if ($rows): ?>
  <div class="view-content">
    <?php print $rows; ?>
  </div>
<?php else: ?>
  <!-- HTML for no results here -->
<?php endif; ?>

You can keep the <?php elseif ($empty): ?> part if you still want to be able to override your custom output.

Cheers,

2
  • Sometimes the simplest solutions are the best (and most maintainable)
    – Rick
    Commented Jun 24, 2014 at 13:44
  • And sometimes you have to weigh the effort between most simple and best. The best might be to try to override/replace the $empty var. This question might be of some help.
    – dxc
    Commented Jun 24, 2014 at 17:44

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.