0

I am able to set this up using a single check for a content in a region, but what if say 3 regions must all have content before the area is displayed?

Here's what I use in my templates when checking for a single region:

<?php if ($content['region-1']): ?>
<p>Region 1 Content</p>
  <?php print render($content['region-1']); ?>
<?php endif; ?>

But for checking multiple regions, Something like this?

<?php if ($content['region-1']['region-2']['region-3']): ?>
<p>Region 1 Content</p>
  <?php print render($content['region-1']); ?>
<p>Region 2 Content</p>
  <?php print render($content['region-1']); ?>
<p>Region 3 Content</p>
  <?php print render($content['region-1']); ?>
<?php endif; ?>
0

This is what I tried just now & it's working --

<?php if ($page['footer_firstcolumn'] && $page['footer_secondcolumn']): ?>
  <div class="footer-firstcolumn">
    <?php print render($page['footer_firstcolumn']); ?>
  </div>
<?php endif; ?>

So I hope if you also try like this with your code with &&, it will work. Something like this--

<?php if ($content['region-1'] && $content['region-2'] && $content['region-3']): ?>
<p>Region 1 Content</p>
  <?php print render($content['region-1']); ?>
<p>Region 2 Content</p>
  <?php print render($content['region-1']); ?>
<p>Region 3 Content</p>
  <?php print render($content['region-1']); ?>
<?php endif; ?>

Otherwise you can take a look here on this documentation to see how you can check whether they are occupied or not in template.php and pass some value with variable to tpl. Then it will be easy to put in condition just like D6.

  • Thanks, I should have thought of that but didn't trust my php ability. This works for me, also I appreciate the advice. – dgdoing Aug 16 '13 at 21:03
1

Your solution will work, but I think the best practice will be to make this check by preprocess 'theme_preprocess_page' and pass the result ( e.g. 'isRegionsEmpty') to the template. Then, in the template you only check one variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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