I've been working on a plugin that updates entry data based on the results from a json array using entries.onBeforeSaveEntry.

Since this API might put out different information in the future, I would like to create an "update all" button that would cycle through all entries and just save them rather than going through each one and clicking save manually.

Any ideas?


If all you want to do is re-save all of the entries without making any modifications to them, you're best bet is to use the completely undocumented TaskService and trigger the ResaveElements task.

There is an example of how to do it from your plugin here.

| improve this answer | |
  • That looks like it might be what I am looking for. Thanks! I am trying to trigger that from a widget that I created for my plugin, and so far I can't get it to work via a button click. I was able to get it to work successfully by hooking into an event (which is how I figured out that it works for me). Any chance I could get an example of how I could do that? Thanks again. – Chris Jul 20 '14 at 1:52
  • Just have your form with the button point to an action on a controller in your plugin (buildwithcraft.com/docs/plugins/controllers). Trigger the task there, then redirect back to where you were. Or you could do it over AJAX since it's from a widget on the dashboard. – Brad Bell Jul 20 '14 at 2:21
  • now that I've been playing with it a bit, it doesn't look like the ResaveElements is actually triggering the entries.onBeforeSaveEntry I have declared in my plugin. Should it trigger that? – Chris Jul 20 '14 at 6:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.