K2 (i found this problem on k2 2.4.1) cant render columns properly (it wont fill the width of the page) if items or subcategories are less than 2 items.
line 89 (for sub categories)
<div class="subCategoryContainer<?php echo $lastContainer; ?>"<?php echo (count($this->subCategories)==1) ? '' : ' style="width:'.number_format(100/$this->params->get('subCatColumns'), 1).'%;"'; ?>>
line 151 (for leading articles)
<div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->leading)==1) ? '' : ' style="width:'.number_format(100/$this->params->get('num_leading_columns'), 1).'%;"'; ?>>
line 179 (for primary items)
<div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->primary)==1) ? '' : ' style="width:'.number_format(100/$this->params->get('num_primary_columns'), 1).'%;"'; ?>>
line 207 (for secondary items)
<div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->secondary)==1) ? '' : ' style="width:'.number_format(100/$this->params->get('num_secondary_columns'), 1).'%;"'; ?>>
line 236 (for link items)
<div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->links)==1) ? '' : ' style="width:'.number_format(100/$this->params->get('num_links_columns'), 1).'%;"'; ?>>
I managed to fix these by changing the second statement, removing the count command and appending the style after the echo.
See example below for sub categories.
<?php echo ' style="width:'.number_format(100/$this->params->get('subCatColumns'), 1).'%;"'; ?>>
I basically removed the
(count($this->subCategories)==1) ? '' : (for sub categories)
(count($this->leading)==1) ? '' : (for leading items)
(count($this->primary)==1) ? '' : (for primary items)
(count($this->secondary)==1) ? '' : (for secondary items)
(count($this->links)==1) ? '' : (for link items)
Can any of the developers please confirm? I'm testing my site and its working fine now, but I just want to make sure i'm doing it right.
Thanks guys and looking forward to your response.