onContentAfterListQuery event ?

40 de afișări
Accesați primul mesaj necitit

Lucas Sanner

necitită,
26 apr. 2018, 08:44:5226.04.2018
– Joomla! Framework Development
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

Michael Babker

necitită,
26 apr. 2018, 10:07:0726.04.2018
– joomla-dev...@googlegroups.com
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.

--
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+unsub...@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-framework.

Răspundeți tuturor
Răspundeți autorului
Redirecționați
0 mesaje noi