Core/getElementsFromParent
From PunchCMS
PCMS_Client->getElementsFromParent(parentId, [getFirst], [recursive])
Overview
Get a collection of elements with a specific parent id.
Arguments
parentId [integer]
Element id of the parent.
getFirst [boolean, optional]
Indicate if you want to get only the first found Element or a collection of Elements. Default is FALSE.
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 Elements are found matching the criteria this method returns a valid Elements object. Otherwise an empty collection. That way you can test if you get a valid return using the count() method.
If the getFirst argument was set to TRUE and an Element was found it will return a valid Element object. Otherwise NULL.
Example
$objCms = PCMS_Client::getInstance(); // Get a collection of child Elements from an Element with id 8779. $objElements = $objCms->getElementsFromParent(8779); foreach ($objElements as $objElement) { // Loop through the collection. }