MODX Community

Extra FirstChildRedirect: additional functionality

The pretty useful extra FirstChildRedirect fell short on one of my sites. It returned a blank page in case the first child resource of a parent resource has been marked as deleted.
To prevent this from happening, add a one-liner:

In the snippet, starting at line 92, you will find the where clause:

$c->where([
    'published' => true,
    'parent' => $parent
]);

Just add the line " ‘deleted’ => false" and make it look like this:

$c->where([
    'published' => true,
    'deleted' => false,
    'parent' => $parent
]);

The extra will now always pick a valid resource. You won’t see a blank page anymore.

This is the link to the original extra:
https://docs.modx.com/current/en/extras/firstchildredirect/index