Difference between revisions of "Collection/orderBy"
From PunchCMS
(New page: __NOTOC__ ==== Collection->orderBy(property, [order]) ==== === Overview === Order a collection of objects by property name ascending or descending. === Arguments === '''property''' [string...) |
(No difference)
|
Latest revision as of 23:06, 25 December 2008
Collection->orderBy(property, [order])
Overview
Order a collection of objects by property name ascending or descending.
Arguments
property [string]
The name of the object property. Could be "created", "sort" or "name".
order [string, optional]
Set the order direction. Can be "asc" to order ascending or "desc" to order descending. Default is "asc".
Returns
Nothing
Example
$objCms = PCMS_Client::getInstance(); // Order Elements by "modified" date descending. $objElements = $objCms->getElementsByTemplate("Page"); $objElements->orderBy("modified", "desc"); foreach ($objElements as $objElement) { // Loop through the elements. }