TransWikia.com

How to update the below action for each view bulk operations? It is for Drupal 7

Drupal Answers Asked by user1768942 on December 30, 2020

I wants to delete the below folder every time only on each view bulk operations but currently it is getting deleted for each node selected in VBO. I am executing this action in rules module.

Please let men know how to run this only once for each VBO.

$pdfdir="/var/www/websites/test/sites/default/files/pdffolder";
$directory = escapeshellarg($pdfdir);
shell_exec("rm -rf $directory");

This is the code executing via Rules Module.

One Answer

If you define a VBO event in rules that triggers on every node save, then it will happen once per node saved by VBO. VBO takes all the selected items in a view and runs them through a batch process, performing operations per item.

So, you need to change the rule event to something else.

If the goal is to run the code once per time, here is one lazy way to do it:

  1. Set the event to be "page is viewed". (doing this from memory, actual event name is different)
  2. Set a condition on the rule to be the path of the VBO page.
  3. Use your execute PHP code as the action.

This will cause the code to execute whenever the VBO url is accessed. This is not exactly what you asked for, but hopefully this gives you an idea of how to use events and conditions in rules to get what you want.

Answered by Patrick Kenny on December 30, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP