Squiz Matrix Batch Change Asset Link Types Using Triggers
Mon, Jul. 18, 2011Today I did some rearranging of some galleries on the Pacific Union College website, and I realized that because of the navigation structure, I needed to change the link type of a bunch of image files. So, rather than manually going to the linking screen for every asset, I figured there had to be a way to do this using triggers and batching.
So, I created a new trigger making sure to set the following options:
Events
- Payment Completed
Conditions
- Tree Locations
- Asset is of type (used image)
Actions
- Create Link - Link as the child of the parent asset (in my case the folder), using a TYPE_2 link (or whatever you want). Make sure to tick "Unlink this asset from all its existing parents.
Notice how for the event, I used a little used event that is not every likely to be used by another trigger on the assets that we are wanting to perform our current trigger on. We are just using it as a way to trigger the batch change.
Run the Batch
Once you have the trigger setup and Enabled, you are ready to run the batch. Find the Trigger Manager in your asset map, right click it and choose Batching. Select the target/parent node that we used in the trigger setup, leave Include Children ticked, and then choose the Payment Completed event.
Click submit to start the batch.
You will see a hippo job start and in most cases you should start to see the assets in the asset map update their link type.
Conclusion
Now all of your assets should be changed to TYPE_2 links, all by using triggers and batching. This solution should scale quite well since the trigger will start a hippo job.
Comments