Hi there, I have been trying to work this out for several hours today and I finally think I have manged to get somewhere.
Firstly, let me say that I am no programmer... I am only just a little above basic understanding / cut and paste, and certainly spend a lot of time with the php site open in another window :)
Creating a overide for mod_k2_content is the way to go, so I did this.. with some pretty simple code added to the top of the new overide default.php as a test.
<?php if(count($items) < 1): ?> // try == 0 or null
<h3> Nothing here</h3>
<?php endif; ?>
It seemed pretty simple because I had done something similar but more complicated for a normal K2 category overide.
But... if the selected category was empty, nothing appeared... Nothing at all. If there was and item returned then it showed up, but no items - no display - not even the title.
So.. I checked my module settings and Hide if Empty was set to No?!?
So to test more, right at the top of the default.php I added <h2>Module Showing</h2> ( above the if(count($items)) section to ensure that the module was not empty even if there were no items to return, and still it did not show.
So it seems the K2 content module ignoresbypasses the "Hide if Empty" parameter.
Confused, I started looking around the actual mod_k2_content code, and at the bottom of mod_k2_content.php, I found a line
if(count($items)){
require(JModuleHelper::getLayoutPath('mod_k2_content', $getTemplate.DS.'default'));
}
Now I'm no programmer and I don't understand all of the module code, but this seemed to be telling me that if there is a 0 (Null) count, then the require once is not loaded (regardless of the parameter), and the module will never display if no items are returned, so I commented out the If statement and .... the module now WORKS even if there are no items in it.
Of course the Hide i empty parameter does not work wither but for my needs (right now) - it does not matter.
I know 'hacking' the core code is certainly not ideal and will get overwritten in future updates, but it got things working for me, and hopefully some of the very smart people in the forum can tell me if this is a bug or if I am totally off the mark and missing the point somewhere :)
I did a little more searching of the code (helper), and it actually looks like the module does not take into account the hide if empty parameter anywhere?!?
I am going to make a copy of the module so it does not get overwritten but as I mentioned above I would love to hear other peoples thoughts on this and what the best way of getting it sorted out would be.
Regards
Michael Tull