Home  »  Blog  »  Squiz Suite  »  Squiz Matrix - change status automatically  

Squiz Matrix - change status automatically

I have recently been given an interesting problem in Squiz Matrix, which appeared to have no solution at first. The requirement was for the status of a folder to change dynamically based on whether it has any standard pages linked underneath it or not. It was clear from the beginning that it had to be done with triggers and after experimenting with different events, conditions and actions, I managed to come up with a solution. It required three triggers, although it should really be only two if it wasn't for what appears to be a bug in Matrix. But more about this later. Here is the solution.

Trigger 1

This trigger will check, if there are any Standard Pages left under the folder every time a page is deleted from under it, and put the folder under construction if theren't any.
  • Event - Link Deleted
  • Condition 1 - Asset ID: set to the folder we want to change the status for
  • Condition 2 - Has a Child/Parent: Make sure the "Inverse this condition" is ticked. The "has a" drop-down is set to "child" and "Of type" is set to "Standard Page"
  • Action - Set status: "Set the Asset's status to" is set to "Under Construction"

Trigger 2

This trigger will set the status of the folder to live if an asset is linked as child of the folder.
  • Event - Link Created
  • Condition - Asset ID: set to ID of the folder we want to change the status for
  • Action - Set status: "Set the Asset's status to" is set to "Live"

Trigger 3

Now, in my opinion, Trigger 2 should be firing, when an asset is created under the folder, since the link is created between a new asset and the folder, but unfortunately it's not. This is what I believe to be a bug I mentioned earlier. In order to overcome the problem, we can create a Temp folder somewhere outside the site and, every time a new asset is created, move it to the temp folder and then back to it's original folder. This will fire Trigger 2.
  • Event - Asset Created
  • Condition 1 - Tree location: set to ID of the folder we want to change the status for. Tick "Immediate child only"
  • Condition 2 - Asset is of type: set this to "Standard Page"
  • Action 1 - Create Link: "Link as the" is set to "Child" and "of the asset" is set to the ID of the Temp folder we created. "Unlink this asset from all its existing parents" needs to be ticked and it's safe to do so, since the trigger will fire on new assets only
  • Action 2 - Create Link: "Link as the" is set to "Child" and "of the asset" is set to the ID of the folder we want to change the status for. "Unlink this asset from all its existing parents" needs to be ticked
That's it! it's a shame that Trigger 2 doesn't pick up new assets. If it did, we could actually apply this process for all the folders under a site, for example, and of course we would avoid the third trigger.

 

 
 

Comments: