Conditionally show Joomla position if it is not empty

Here's a useful Jooma template coding, php snippet:

<?php if($this->countModules('position1')) : ?>
<?php endif; ?>

This will only show position 'position1' and its wrapping div if the position contains a module.

Whoever posted this....thank you! I'm working on my site and have only basic php/css knowledge...though I'm trying. I needed a module's div wrapper(which had margins that would show up) to disappear if the module inside it did not display. It's the slider module at the top. On secondary pages, I needed that gone...but the div wrapper's margins would display even if the module didn't.
I know this is probably a very simple solution...but I didn't know it. I found what you posted after searching the internet for a frustrated day. I was not expecting it to work...and it did. Like a charm.
You have no idea how much I love you! :)

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.