A
A
Aljo2022-04-03 10:51:36
MODX
Aljo, 2022-04-03 10:51:36

How to check if resource is msCategory by id?

Actually the question is:
how to check if the resource is msCategory by id?
If not, then get the id of all child resources with the msCategory class.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Danny Arty, 2022-04-03
@aljo222

If you need child categories of the 1st nesting level

if (!$cat = $modx->getObject('msCategory', $id)) {
    $res = $modx->getCollection('msCategory', array('parent' => $id));
    $ids = array_keys($res); // Массив с id дочерних категорий
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question