Subcategories title in category or blog view with multiple columns in Joomla

First of all thanks to Viktor which helped me a lot defining the final solution. You can find his post here.

Now his tricks works well if you have only one column that shows your articles. Now what if your category view shows 3 or 4 columns? You need to tell Joomla to have a line break when you switch to a new subcategory and that’s the tricky part.

We still need to tweak the following files:

Blog View


Category view


Blog view


Category View


On the following examples we’ll work with the file category.php on Joomla 3.4.1. The tweak should be very similar though on Joomla 2.5 or 3.3. This tweak works only if you don’t have any leading items. The following example is based on a 4 columns page.

Look for this line

</div><!-- end items-leading -->

This is the end of the leading items section and therefore the beginning of the standard articles section.

Just after 

$counter = 0;

Add the following lines:

$rowcount = 0;
$firstiteration = true;

This will be used instead of the regular $rowcount iteration.

Now comment out the line

$rowcount = (((int) $key) % (int) $this->columns) + 1;

and replace it with


After the row

$row = $counter / $this->columns;

And this:

$this->item = &$item;
$subcat = $this->item->category_title;
if ($subcat != $psubcat) :
$rowcount = 1;
$rowcountbeingreset = true;
endif; if ($subcat != $psubcat) :
if ($firstiteration == false){
</div><!-- end row custom -->
echo "<div style=\"width:100%\"><h2>" . $subcat . "</h2></div>";
$psubcat = $subcat;

That will basically replace the automatic row counting system and instead create Title for subcategories and line break before each title.

And that’s it! Trick’s done. You can request a zip copy of the PHP file here if that can be of any help. Happy tweaking!