I’m just learning snippets, so bear with me if I say something totally off-base:
I have a page for which I know the id. All I want to do it obtain the pagetitle of that page. Everywhere I searched for how to do this I have found how to output the title of the CURRENT page (via $modx->resource->get()), but not for some arbitrary page. It looks like I could do it with $modx->getDocument(), but the API says that method has been depricated.
Thanks!
-
☆ A M B ☆
- 24,524 Posts
Is this Evolution or Revolution? The APIs are different.
Thanks for the reply.
I’m working in Revolution.
In Revolution, it would be
$id = 12;
$resource = $modx->getObject('modResource',$id);
$pgTitle = $resource->get('pagetitle');
FYI, the method above is a shortcut if you know the ID.
The more generic method would be something like:
$resource = $modx->getobject('modResource',array('published'=>'1', alias='myDoc'));