The snippet code -
The first line gets the "value" property of the snippet (the &value part of the snippet call), setting a sane default of the current resource ID if no &value property is used. This is the resource that actually has the getResources snippet in it (or in its template).
The second line gets a collection of TVs where the TV ID is #1 (you will need to edit this to be the actual ID of the TV you are using), and where its value is &val (either the &value in the snippet call, or the ID of the current resource). This comes from the site_tmplvar_contentvalues table in the database, which has the TV id, the id of the resource, and the value set for that resource. I really should add to the code to support another property, the name of the TV, but it was getting late and I was getting tired
Since the getCollection() function returns an array of whatever objects we asked it for, we use the foreach() PHP looping structure to deal with each TV found, one at a time. We're converting each TV object to an array, and grabbing its "contentid" value - that is the ID of the resource where the specified value is set.
Since we told it to add a comma after each one, we need to get rid of the last comma, so we tell PHP to trim off the right-most comma. We'll end up with a comma-separated list of all the resource IDs that have the TV set to our specified value.
And that's exactly what the getResources snippet wants for its &resources property, a comma-separated list of resources to display. I believe you should be able to use &parents=`-1` in getResources to tell it to ignore the &parents property and only use &resources; that doesn't work in pdoResources.
[ed. note: sottwell last edited this post 12 years, 4 months ago.]