API:getDocumentObject

From MODx Wiki

Jump to: navigation, search
 API Function Definition: 
getDocumentObject
Versions 
> 0.9.2 (?)
Return Values
Success: (the document)
Fail: (empty)
Data Type 
Array
Object Hierarchy 
DocumentParser
Array getDocumentObject(string $method, mixed $identifier);


Retrieves a Document from the database. Document permissions are verified. The document is returned in the form of an array on success. An empty array is returned if the document does not exist. If the document exists but the user is not authorized, the parser calls sendUnauthorizedPage and exits.

  • $method should be either 'id' or 'alias'
  • $identifier will be type string or int depending on $method.

Examples

// Get the home page title
$homeDoc = $modx->getDocumentObject('id',1);
$title = $homeDoc['pagetitle'];
echo "<h1>{$title}</h1>";
echo htmlspecialchars(print_r($homeDoc,true));

Related Functions

Function Source

File: manager/includes/documentparser.inc.php
Line: 880

Notes

Personal tools