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

Integrating Tiny with Vue in a real world application

TinyMCE 5 has made the setup process more straightforward - and even easier with the Cloud version. And as there are so many JS frameworks out there, Tiny have...

Continue reading...


Extending the ItemHelper for Joomla

There are times in Joomla where you want a bit of control over your content at the template override level – such as showing the first X characters of a string. PHP...

Continue reading...


How Tiny helps me deliver the best content authoring experience

At Joomla Day Australia 2019 in Brisbane, I spoke about how TinyMCE helps deliver the best content authoring experience. And for those who couldn’t make it on...

Continue reading...


How to show real-time highlights and shadows clipping in Photoshop

I’ve used Photoshop for years. Decades even. Yikes, showing age there. But for my photography, I tended to use Photoshop for specific things – such as cleaning...

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