Hi all,
I just made a pull request
https://github.com/joomla/joomla-cms/pull/3705 for the mod_articles_popular module to add an if-empty check before showing any HTML output. This makes sure that the module does not show on the frontend (not even its module title) when the articles array is empty anyway. I took the approach here of adding the if-empty check within the layout template, so that a developer could still add in a "No items" error if wanted.
In the GitHub pull request discussion, @Bakual brought up the question whether the layout template should be used at all (tmpl/default.php) and if it wouldn't be a better idea to add it in the main file instead (mod_articles_popular.php). There is perhaps something to say for both situations.
After the comments of @Bakual and @sovainfo I checked the Joomla! core and found the various core modules to very inconsistent here:
A) Modules that stop output in the layout file:
modules/mod_articles_archive/tmpl/default.php
modules/mod_tags_popular/tmpl/default.php
modules/mod_users_latest/tmpl/default.php
B) Modules that stop output in the main file:
modules/mod_articles_category/mod_articles_category.php
modules/mod_related_items/mod_related_items.php
modules/mod_tags_similar/mod_tags_similar.php
modules/mod_weblinks/mod_weblinks.php
C) Modules that just output HTML even when the list is empty:
modules/mod_articles_categories/tmpl/default.php
modules/mod_articles_latest/tmpl/default.php
The approach under point A is the approach I took. There are quite a bunch of modules of approach B though. And the modules under approach C simply need fixing in my opinion.
We can make this happen by either modifying all modules to be using approach A, approach B or perhaps even an XML-switch to allow the administrator to switch between approach A and B (which sounds overly complex though).
Which approach should we take?
Regards,
Jisse Reitsma