Y
Y
Yuriy2019-01-10 10:49:44
MODX
Yuriy, 2019-01-10 10:49:44

How to display a specific object from a resource?

Tell me how to display (get access to data) to the resource object?
Created a resource: Recipes
Resource type: Collection
Created child resources in this resource,
5c370635e64dd551115554.png
you need to display a specific collection element (recipe) on a certain page.
how to access recipe data via snippet?
$res = $modx->getObject('CollectionContainer',137);
seems to display, but a warning appears in the admin
panel public_html\core\xpdo\om\xpdoobject.class.php : 344) Instantiated a derived class modDocument that is not a subclass of the requested class CollectionContainer
something is wrong...
modx revo

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Romanov, 2019-01-10
@yous

Do you need to get the data of some recipe or resource-container "Recipes"?
If the former, then use the usual tools like pdoResources or getResources - after all, the "daughters" of the collections are just resources that are hidden in the tree.
If the latter, then use modResource:
$res = $modx->getObject('modResource', 137);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question