The PageList class provides an object-oriented way to search pages. Since it extends the DatabaseItemList, it also provides pagination and sorting.
Instantiating the PageList object
Loader::model('page_list'); $pl = new PageList();
Filtering Methods Available
When called, this will instruct the PageList query that you don't want to check the permissions of the logged-in user. This may result in the page list including pages that user cannot view.
Instructs the page list to ignore aliased pages.
Instructs the page list to include system pages (e.g. the dashboard).
Instructs the page list to include pages that have not yet been approved.
Filters files by keywords, which searches
- Name, Description, Indexed Content against MySQL fulltext functions
- Any collection attributes marked as being included in the search index
$pl->filterByName($name, $exact = false)
Filters the page list by page name.
$pl->filterByPath($path, $includeAllChildren = true)
Filters pages by path. Allows for just the immediate children or all to be searched.
Filters pages by the parent ID of a given page.
Only displays pages of a certain page type.
Only displays pages owned by a particular user ID.
Only displays pages that are either approved or not (depending on the passed value of $isApproved.)
Filters by whether an item is an alias or not.
Filters by page type handles. $ctHandle can also be an array of page type handles.
$pl->filterByDateAdded($date, $comparison = '=')
Filters by date the page was added. $comparison can be any MySQL comparison operator.
$pl->filterByPublicDate($date, $comparison = '=')
Filters by public date. $comparison can be any MySQL comparison operator.
$pl->filterByNumberOfChildren($number, $comparison = '=')
Filters by number of page children. $comparison can be any MySQL comparison operator.
$pl->filterByAttribute($attributeKeyHandle, $value, $comparison)
Filters by attribute.
$pl->filter($column, $value, $comparison)
Passes a fliter directly to the "WHERE" clause. The value of $column must be a valid database column that's referenced in the PageList query. Setting the value of $column to false will allow you to pass complex SQL into the $value field ex:
$pl->filter(false, '(ak_age = 10 OR ak_age IN (13,17,25) OR ak_age > 23)');
where 'age' would be the handle of a numeric page attribute
Orders by index score descending. Only available when searching by keywords.
Orders by sitemap display order ascending.
Orders by sitemap display order descending.
Orders by public date ascending.
Orders by public date descending.
Orders by page name ascending.
Orders by name descending.
$pages = $pl->get($itemsToGet = 100, $offset = 0)
Gets all pages that fit the criteria.
$pl->getPage($page = false)
Gets a page of pages (taking into account $itemsPerPage, current page, etc...)