Modx revo 2.4.2 Get resource level

191 views Asked by At

I'm using getResource and I would like to retrieve resource's level to create conditions. I found an old script but it does not work anymore with modx 2.4.2:

<?php
/*GetLevel snippet */
$parentIds = $modx->getParentIds($modx->resource->get('id'))
return count($parentIds);

It crashes the website. Can someone help or update the code above? Thank you!

1

There are 1 answers

0
Sylvain Le Bihan On

It was just missing a semicolon :

/*GetLevel snippet */
$parentIds = $modx->getParentIds($modx->resource->get('id'));
return count($parentIds);