How to prevent Joomla empty modules from being rendered? To achieve this-

I have tried by returning false from module's entry file if there is no output. I have written following code in modules entry file eg mod_xyx.php

// Hide mod when no output.
if ( @no_output)
    return ;

It works for Joomla's default template but doesn't work for some template.


2 Answers 2


If you are 100% sure that your module output is empty, then your template may be adding a chrome to the module.

You can check how the JModuleHelper::renderModule generates the module output and (optionally) calls the template chrome.



I've encountered this in the past, and your answer is likely in your template files...you'll probably see that its checking if there is a count of modules - something like this from Protostar:

<?php if ($this->countModules('position-8')) : ?>
<!-- Begin Sidebar -->
<div id="sidebar" class="span3">
    <div class="sidebar-nav">
        <jdoc:include type="modules" name="position-8" style="xhtml" />
<!-- End Sidebar -->
<?php endif; ?>

It doesn't consider whether there is output or not, so renders the module position regardless of what is/isn't rendered.

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.