Blog

Squiz Matrix Batch Change Asset Link Types Using Triggers

Mon, Jul. 18, 2011

Today 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.

  • iphone

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.

  • iphone

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.

  • iphone

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.

  • iphone
  • iphone

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.

Nicholas Hubbard
Owner

Comments

Paul Wojciechowski
Jul 19, 2011
Once I used similar way to set for all images "allow_unrestricted" value to "0". This made images load slower (they was served by Matrix) but I needed to use some gallery that was relying on webpaths and Matrix by default set them all to "__data" paths.
Nicholas Hubbard
Jul 19, 2011
Yeah, it really is a nice way to quickly make these changes. Gotta love triggers.

Add Comment