API:getPageInfo

From MODx Wiki

Jump to: navigation, search

Gets the specified fields from specifed document ID

Usage

array = getPageInfo($pageid= -1, $active= 1, $fields= 'id, pagetitle, description, alias');


Example

$array = $modx->getPageInfo($id,1,'content'); $content = $array['content'];

Source Code

File: manager/includes/document.parser.class.inc.php
Line: 1441
function getPageInfo($pageid= -1, $active= 1, $fields= 'id, pagetitle, description, alias') {
        if ($pageid == 0) {
            return false;
        } else {
            $tblsc= $this->getFullTableName("site_content");
            $tbldg= $this->getFullTableName("document_groups");
            $activeSql= $active == 1 ? "AND sc.published=1 AND sc.deleted=0" : "";
            // modify field names to use sc. table reference
            $fields= 'sc.' . implode(',sc.', preg_replace("/^\s/i", "", explode(',', $fields)));
            // get document groups for current user
            if ($docgrp= $this->getUserDocGroups())
                $docgrp= implode(",", $docgrp);
            $access= ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") .
             (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
            $sql= "SELECT $fields
                    FROM $tblsc sc
                    LEFT JOIN $tbldg dg on dg.document = sc.id
                    WHERE (sc.id=$pageid $activeSql)
                    AND ($access)
                    LIMIT 1 ";
            $result= $this->dbQuery($sql);
            $pageInfo= @ $this->fetchRow($result);
            return $pageInfo;
        }
    }
Personal tools