Joomla components use Models to fetch data (like articles) from the database. We would like to introduce two new Plugin Events in component models, which allows you to tweak queries using plugins.
If you want to change the query of for instance the front-end ArticlesModel, then you can't.
Or you have to use a cumbersome workaround: create a system plugin that loads your own changed copy of the ArticlesModel before Joomla does. However, such a "model override" is difficult and there's no option like with Template Overrides to see if there are any changes in the Joomla core model after Joomla updates.
Therefore we would like to have two new plugin events where you can hook into the filtering
and into the query
of the Model to modify the query.
In the back-end via Content > Articles you get an overview of all articles.
If you want to add an extra column to display the intro image of an article, you can create a template override.
However, the "images" field that contains the "intro_image" is not in the query to retrieve the articles.
Add a database query in the template override is not the right way, and might slow down the page.
And if you want to add an extra filter in the override (e.g. to filter images on (non) availability of the intro image), then you can't.
It would be handy to have two new plugin events in /administrator/components/com_content/src/Model/ArticlesModel.php
in the methods:
With new plugin events in those methods, you could hook into them.
And have your plugin add new filters and extra queries to the $query object.
The front-end Category Blog loads all articles from a specific category.
With new plugin events you can have your own plugins modify the query to add or remove items from the list.
It would be handy to have two new plugin events in
In /components/com_content/src/Model/CategoryModel.php
With new plugin events in those methods, you could hook into them.
And have your plugin add new filters and extra queries to the $query object.
Labels |
Added:
No Code Attached Yet
|
Labels |
Added:
Feature
|
There is a reason we don't have this, don't have the time to find the relevant issues here in github but we have several of them. One of the things is our database schema is not part of the b/c policy.
Just to get it not wrong, you want this for all models and not only for com_content?
First in com_content, later maybe in other models as well.
This dates back a looooong way https://groups.google.com/g/joomla-dev-cms/c/KkGuhBYvoyo/m/sTILTLIqfXIJ
But for all the reasons. This quickly decents into plugin per database query. The performance is bad. The chance of database queries stepping over each other is high. I'm very against this.
Especially the removing of items. That's why it's a bad idea!
Thanks for sharing that link @wilsonge - my main takeaway from all of that was this from Andrew
But more than than, ad hoc altering of a query is a dangerous practice to move forward with (testability, introducing slow queries, bad joins, changing physical behaviour of the original query, collisions on the same query from two developers, etc and so on)
I don't see anything that has changed in Joomla, Extension Developer practices, or this proposal that changes this
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2024-06-12 18:04:48 |
Closed_By | ⇒ | rdeutz |
This possible future feature has been discussed in yesterday's weekly CMS Maintenance meeting.
However, it was decided that the feature could be too risky, potentially causing numerous issues if multiple plugins would run simultaneously and change the queries.
Just to get it not wrong, you want this for all models and not only for com_content?