Reputation: 4426
I have a custom template that renderes a module in some position. The module does a query to database and renders according to the results. However, if the query to database returns empty rows, module does not have to be shown.
I have this in the template:
<!-- lo más de la semana -->
<?php if ($this->countModules('lo-mas') > 0): ?>
<div class="row">
<div class="lomas"> <h3>LO MÁS DE LA SEMANA</h3></div>
<jdoc:include type="modules" name="lo-mas" />
</div>
<?php endif; ?>
<!-- fin lo más de la semana -->
I can have several modules at "lo-mas" position, but if, for some reason, all of the modules does not render any output, I don't want the title to be shown ("LO MÁS DE LA SEMANA")
Is this possible in Joomla 3?
Upvotes: 1
Views: 718
Reputation: 4589
I think you can solve this by rendering the modules a little more manually:
<?php
jimport( 'joomla.application.module.helper' );
$modules = JModuleHelper::getModules( 'lo-mas' );
$output = '';
foreach ($modules as $module) {
$output .= JModuleHelper::renderModule($module);
}
if (trim($output)){
?>
<div class="row">
<div class="lomas"> <h3>LO MÁS DE LA SEMANA</h3></div>
<?php echo $output; ?>
</div>
<?php
}
?>
You can probably decide exactly how your modules are rendered by specifying the style somehow (usually xhtml), and applying some more html-code to the output...
Upvotes: 1