I need to trigger code when an article is moved from one category to another.
onContentAfterSave
works fine for a single article, but what if I move articles via Actions -> Batch? Is there a trigger for that?
Joomla Stack Exchange is a question and answer site for Joomla! administrators, users, developers and designers. It only takes a minute to sign up.
Sign up to join this communityThere is an event regarding batch process:
onBeforeBatch(BeforeBatchEvent $event)
and the $event array param is passing the source Table and the type of batch operation, however I have never seen this in use in any plugin.
But what I think is useful event for you to use most probably, without knowing the full purpose, is the
onTableAfterStore(AfterStoreEvent $event)
This event is firing right after the batch operation and the $event param in this case is passing the table and the result
// Extract arguments
/** @var TableInterface $table */
$table = $event['subject'];
$result = $event['result'];
References to onBeforeBatch
event:
This Event class is defined in src/Event/Model/ : https://github.com/joomla/joomla-cms/tree/4.3-dev/libraries/src/Event/Model
According to my fast test in Joomla core taggable plugin, this event is firing when we do a copy type Batch operation on content(articles) items (so at move type operation it does not), so it ignites when we are copying items. I have not checked yet why it is that way.
The event is used in Behaviour/taggable core plugin: https://github.com/joomla/joomla-cms/blob/4.3-dev/plugins/behaviour/taggable/src/Extension/Taggable.php
And the event is property of the Admin Model in Joomla: https://github.com/joomla/joomla-cms/blob/4.3-dev/libraries/src/MVC/Model/AdminModel.php