get list of pages

Submitted by remo - 5 years ago

if you need a list of pages, use the PageList class, it gives you a nice interface hiding a lot of the complexity in the background.

// manually load PageList class, not required if you're using 5.6 or higher
if (version_compare(APP_VERSION, '5.6.0', '<')) {
    Loader::model('page_list');
}

$pl = new PageList();

// filter all items where exclude_nav is 1
$pl->filterByAttribute('exclude_nav', 1);

// the same as above, but this time, there's a PHP magic method converting the
// camel-cased method following "filterBy" into the snake-case attribute handle
$pl->filterByExcludeNav(1);

// get the current page of items, use this when you need pagination support
$pages = $pl->getPage();

// gets a fixed number of items, use 0 to get all items but use it with care!
$pages = $pl->get(100);
Stats Categories Tags
comments powered by Disqus