Blog: PHP

The strengths (and limits) of Joomla's overrides


I’ve developed a few sites using Joomla – this is one of them. And one of the best parts of Joomla are the layout overrides.

Nothing irks me more than when a developer decides to update core files of a framework or library – and then wonders why updating to the next version breaks their site.

Joomla knows this, and has given developers the ability to use layout overrides – basically make a copy of core files within the template folder, but edit them to our hearts content. When we go to update Joomla to the next minor version, if we’ve been a good developer, it should all work as expected.

I think this is totally brilliant – the core Joomla layouts are deeeetailed, so I can make my overrides do whatever I need to do.

This site has so many – content layouts, blog layouts, music layouts, tag layouts – but I have so much control over them all. And none of the core Joomla code is changed.

That’s pretty awesome non-destructive editing.

I love it - I can have full control over my layout - and in the instance of this site, was able to get the outputting markup for all needed areas to be in the Bulma-ready format to take advantage of the Bulma CSS framework.

This is really smart, really handy, and really easy to do.

But, there was one issue I had with the pagination markup.

The core Pagination.php file within Joomla’s core library is trying to force me to use Bootstrap on the front end of my website. No. Don’t. Please don’t.

I would run my code – and it would look alright – but I saw a JavaScript error in the Console – and it referenced Bootstrap. In the head of my template, there is no Bootstrap – I’m not using it. So it got me hunting around. View source, and yep, there it is. Go to a blog listing with no pagination and it's gone.

I could disable it on the category list views – but as soon as the number of articles enabled pagination, the error came back.

In the core Pagination class (libraries/src/Pagination/Pagination.php), there is this lovely line:


Basically this is telling Joomla to use Bootstrap. OK fair enough, it adds functionality for some users – but for a control nut like me, you’re not giving me the ability to (easily) disable it.

From an Admin interface perspective, I’ve got nothing against Bootstrap – but on the front end, I don’t like being forced to use something I don’t want or need for the specific project.

Ideally, a setting within the Joomla setup (or even in my main template php file) to globally enable/disable Bootstrap helpers like this (on the front end) would be perfect.

But instead, I had to create an override called pagination.php in my template’s html folder, and adding the following functions:

function pagination_list_render($list)
return \JLayoutHelper::render('joomla.pagination.list', array('list' => $list));

function pagination_item_active(&$item)
return '<a href="' . $item->link . '" class="item-nav">' . $item->text . '</a>';

function pagination_item_inactive(&$item)
return '<span class="pagenav">' . $item->text . '</span>';

This overrides the functions of the Pagination.php file and fixes the issue (i.e. bypasses any calling of the bootstrap.tooltip enabler), but doesn’t follow the same structure of any other override.

So logically, yes, it’s fixed, but seems like there could (or should?) be a better or cleaner way to do this without overriding functions like this.

Given not every one uses Bootstrap, I think the best solution - at the core Joomla or template level - is the ability to disable any calls that would otherwise enable Bootstrap. So that way if someone does want to use it, they can, and Joomla works as expected. But for those who don't want to use it, a simple call at the template (or Joomla config) could just make those calls not output anything to the template. Tools like jQuery Easy are good for setting versions - and disabling Bootstrap - but if I disable Bootstrap, it would be good for Joomla to acknowledge this for the entire front end.


View all

2020: refreshing the life of a long term developer

2020 has been incredibly refreshing. Let’s also be blunt, it’s been completely shit for so many too – including isolation from family and months of Stage...

Continue reading...


Astro's Playroom

Astro’s Playroom. It’s free, and comes pre-installed on your PS5. It is basically a tech demo wrapped up in a platformer. And a pretty fun platformer too. And...

Continue reading...


Creating a TinyMCE addon for Statamic 3

It’s no secret: I do love TinyMCE. It provides an excellent authoring experience, that produces clean and reliable HTML, and can easily be customised and extended...

Continue reading...


Installing and review of the Sonos Wall Mount with the Sonos One SL

I’m new to the Sonos ecosystem, and after setting up the Sonos Arc and Sub combination, I wanted more, so splurged on a pair of One SL speakers for surrounds....

Continue reading...

I am the Development Director (and co-owner) at Mity Digital, a Melbourne-based digital agency specialising in responsive web design, custom web development and graphic design.
Mity Digital