I have a similar need, Mark4 - good of ya to ask - I was just searching for that function.
and btw - it works just fine in CMS - Just remember to return a variable of $results as instructed. The scripts above in the root post refer to $output..
1_ Admin CP - CMS - Widget Manager - Create Widget - Direct PHP execution type - Give it a title.
2) Select configure from the list after the addd of the widget and the code above of your choice. I will assume you know how to copy the code block and paste it.
3) In your pasted block, scroll all the way to the end - If the one you copied ends like this
Then change it to this:
Save it, and then add the block to a page layout you are using. Worked just like that for me in 4.1.1
now, to customize it by event
Cheers