Blog: PHP

The strengths (and limits) of Joomla's overrides

Published

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:

JHtml::_('bootstrap.tooltip');

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.

Blog

View all
PHP

How to easily access to Custom Fields in Joomla

Over the past few years, I’ve had to get more and more involved in developing Joomla websites. Joomla is such a powerful, flexible and user-friendly CMS to work...

Continue reading...

Movie

“Gravity” and Dolby Atmos

Gravity is one of those movies that I missed in theatres, but watched in 3D on Blu-ray when it first came out. I had just gotten a 3D TV and, hey, any disc with...

Continue reading...

Photo

Making photos fit on your website

As you know, I love my work as a web developer. I also love taking my landscape photographs. So it only seemed natural that when Mity wanted someone to write about...

Continue reading...

JS

vue-slide-up-down: helping improve accessibility

When starting out in Vue, coming from jQuery, one thing that I did miss was the jQuery slideUp and slideDown functions. They’re just so convenient, easy and effortless...

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