Resource List TV to show only children of current resource?

Is there a way to get the TV input type “Resource List” to show only the children of the current resource? I thought maybe something like [[*id]] in the Parents field would work, but that only accepts real numbers.

I think you could do this with a custom TV and a plugin that returns what you want using $resource->get('id) but it’s fairly complex. At one time you could simply use @eval but I’m pretty sure that’s no longer an option. I couldn’t make it work with [[*id]] and @select even with preprocess tags turned on. Someone else may have a better idea.

This is a weird one.

I looked at the code to see how the settings are being processed and for the “parent” there is indeed some bindings processing that happens. However bindings are not possible in the “Parents” field (of the TV Input Options), only for the database-column elements (which I don’t think can be filled in for a TV of type “Resource List” directly from the MODX 3.2.0 manager).

So here is a possible solution that kinda works:

  • In the “Input Options” tab of the “Resource List” TV, leave the “Parents” field empty.
  • Go directly to the database table modx_site_tmplvars and change the column elements (for the row of the “resourcelist” TV) to something like @SNIPPET getCurrentResourceId.
  • Create a snippet getCurrentResourceId with code like this:
<?php
return $modx->resource->get('id');