Core/get

From PunchCMS
Revision as of 17:00, 25 December 2008 by Admin (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

PCMS_Client->get([elementApiName], [recursive])

Overview

Get the first element or folder from the root folder of the CMS. It is possible to select an element with a specific api name and to search recursivly through the element tree.

Arguments

elementApiName [string, optional]
API name of the element you are looking for.

recursive [boolean, optional]
Indicate if you want to search trough the tree or only on the first level. Setting this to TRUE can be very time consuming. Default is FALSE.

Returns

If an element is found matching the criteria this method returns a valid Element object. Otherwise NULL. That way you can test if you get a valid return using the is_object() method.

Example

$objCms = PCMS_Client::getInstance();
 
$objElement = $objCms->get("Menu");
if (is_object($objElement)) {
    // Found Element with API name.
}