Difference between revisions of "Core/get"

From PunchCMS
Jump to: navigation, search
(New page: __NOTOC__ ==== 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 wi...)
 
(Returns)
 
(2 intermediate revisions by the same user not shown)
Line 10: Line 10:
 
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'''.
 
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 ===
 
=== Returns ===
If an element is found matching the criteria this method returns a valid Element object. Otherwise NULL. <br>
+
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 [http://www.php.net/manual/en/function.is-object.php is_object()] method.
That way you can test if you get a valid return using the [[http://www.php.net/manual/en/function.is-object.php|is_object()]] method.
+
 
 
=== Example ===
 
=== Example ===
 
<source lang="php">
 
<source lang="php">

Latest revision as of 17:00, 25 December 2008

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.
}