Tell me, please, how to implement this. There is a resource tree:

ресурс вложенный ресурс 

in chunk generat link so Makar

 [[~[[+id]]]] 

This link to your own resource, how to make the link lead to a nested resource ???

    2 answers 2

    I understand that you insert a chunk into a resource and the link is obtained on the resource itself, but on the child? Try using this snippet .

    • I apologize maybe I didn’t put it right, the snippet works, the fact is that I need everything exactly to the reverse, so that the link would lead from the root resource to the resource invested in it. - webkostya

    Hooray solution found.

    1) Create a snippet with this content.

     $depth = isset($depth) ? $options : '1'; // default limit to 1 levels deep $array_ids = $modx->getChildIds($input,$depth,array('context' => $modx->context->key)); if(!is_array($array_ids)) return $input; // if no children, we will return the id resource return $array_ids[0]; 

    2) Call it in the template with this method

     [[~[[+id:getChildIdResoirceId]]]] 

    3) By default, the depth is 1, if you need to change it, just pass in the options, i.e. for example on 3

      [[~[[+id:getChildIdResoirceId=`3`]]]] 

    That's all the solution. A big thank you to the MODx forum, namely Artdevue