[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [jfw] onContentAfterListQuery event ?



Proposals to add plugin events allowing query manipulation have been shot down pretty hard over the years and really aren't a good practice to accept.

On Thu, Apr 26, 2018 at 7:44 AM, Lucas Sanner <lucas.sanner AT gmail.com> wrote:
Hi,

In my components I very often use plugins to handle the various trigger events sent by the Joomla framework all along the several workflows as save, delete etc..
It's a powerfull and clean way to achieve my aims without using dirty hacks. 
However, a trigger event which allow to override list queries is sorely lacking. 
It would be great to modify some component's queries whenever it's needed.
Such trigger is actually pretty easy to implement in the Joomla library.

In the libraries/src/MVC/Model/ListModel.php file at the end of the _getListQuery() function, just add the following:
protected function _getListQuery()
{
  ...

  \JPluginHelper::importPlugin('content');
  $dispatcher = \JEventDispatcher::getInstance();
  $dispatcher->trigger('onContentAfterListQuery', array($this->context, $this->query));

  return $this->query;
}

Then you just have to handle the event in your content plugin:

public function onContentAfterListQuery($context, $query)
{          
   //Do whatever you want here...
}

Would it be possible to add this trigger event in a future Joomla version ?
Where can I submit this proposal ?

Thanks

--
Framework source code: https://github.com/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-framework.

--
Framework source code: https://github.com/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-framework.