User tests: Successful: Unsuccessful:
This is an adapted PR of #7594
Templates use the $this->countModules('myposition')
to determine whether or not to show a position (and surrounding html).
However, when a module is empty (no content), the countModules
is not affected.
This can result in positions being shown with no modules in it.
This PR adds the option to not include empty modules in that count.
This can be done by adding false
as second argument (setting $include_empty
to false
):
$this->countModules('myposition', false)
Easiest way to test with an empty module is to use Advanced Module Manager, as that will make the content truly empty even if the module has an empty <p></p>
tag.
So just make a Custom HTML Module and leave the content area empty. Assign it to a module position (that has no other modules assigned to it). Like manually entering testempty
in the module position field. And switch on the 'Hide if Empty' option.
Or create your own module that returns an empty content.
Then in your template place this somewhere:
<?php
echo "\n\n<pre>==========================\n";
echo 'Real module count for position "testempty": ' . $this->countModules('testempty');
echo "\n==========================\n";
echo 'Not-empty module count for position "testempty": ' . $this->countModules('testempty', false);
echo "\n==========================</pre>\n\n";
?>
In my opinion the default for $include_empty
should be false
.
As people are saying in #7594 that would change behaviour. That is true, but I believe it only changes it in edge cases and only when those edge cases don't want the empty modules to be counted.
However, that isn't worth my time to fight for, so hope this 'addition' instead of a 'fix' does get accepted.
Then it is up to the template developers to implement it.
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
Yep, I see what you mean.
Oh well, seems like what I want is not possible with how Joomla core goes about module collection and rendering.
I'll not waste any more of my and others time on this.
Thanks for testing.
Closed.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-08-01 15:37:42 |
Closed_By | ⇒ | nonumber |
Well, here still something wrong with the logic,
first need to define what is "empty module",
because from point of view if module exist it cannot be empty, because it have at least
id
And on time when someone call
countModules
in the templateindex.php
there not exists any module that hascontent
, exceptcustom html
module ... "menu module", "latest articles module" and other, do not have content on this point of time.I tested in joomla test installation and in the protostar template:
so, from my point of view such changes will confuse people a lot more than before