checking if modules are empty

Locked
ewel
Joomla! Guru
Joomla! Guru
Posts: 522
Joined: Mon Oct 01, 2007 11:35 am

checking if modules are empty

Post by ewel » Sun Nov 08, 2009 1:56 am

Sometimes modules do not produce any output on certain pages. At the moment, few modules perform that trick, but perhaps more would if this feature request is adopted. Already there are two modules which show or hide other modules dependent on what page is viewed, Mod OnAnyPage (MOAP) and Meta Mod. Between them these modules have many thousands of users.

As the developer of MOAP I have had a lot of support requests about module chrome, often about module chrome preventing a column from collapsing. The html tags of the module chrome are still in the output when MOAP tries to hide the module published through it, because MOAP is active in a page so as to show or hide the output of other modules. A work-around would be to change the template and change the module chrome to raw. However, that work-around prevents other modules from displaying properly in the same position. Creating a plugin to conditionally remove chrome is not an option either.

However, a simple solution would be to change just a few lines in ibraries\joomla\application\module\helper.php. In line 205 this:

Code: Select all

$chromeMethod = 'modChrome_'.$style;
can be replaced by this:

Code: Select all

if(!empty($module->content)){
    $chromeMethod = 'modChrome_'.$style;
} else {
    $chromeMethod = 'modChrome_raw';
}
The result of this change is that normal modules continue to be displayed with module chrome as always, but modules that show or hide their output conditionally will truly disappear if they do not produce any output, because the module chrome is not part of the output if there is no module output.

Users of conditional modules could hack the core files in this way, but obviously hacking does not work well with updates.

Since this is a minor change, without side-effects or backwards-compatibility issues, which would help thousands of users and might open doors for new module development, I hope this feature request will be adopted.

Locked

Return to “Feature Requests - White Papers - Archived”