$pages


Built-in Methods Reference

$pages->find("selector")

Introduced in Version 2.0

Description

Find and return all pages matching the given selector string. Returns a filtered PageArray unless an include mode is specified.

Return value

Returns a filtered PageArray that excludes hidden, unpublished and no-access pages, unless an include mode is specified. To specify an include mode, have your selector string argument have an "include=x", where "x" is "hidden", "unpublished" or "all". 

Pagination

This method supports pagination when an "limit=10" is specified in the selector string, where "10" may be any  number that you want to limit each pagination count to. ProcessWire automatically identifies the page number from the URL (assuming page numbers are enabled in the rendered page's template settings). To paginate manually, you may also specify a "start=0" in your selector, where "0" may be a number representing the zero-based index of the first page you want to start the results with.  

Examples

Find all skyscrapers (i.e. pages using the skyscraper template). Then make a list linking to each of them.

$skyscrapers = $pages->find("template=skyscraper, sort=-modified");
foreach($skyscrapers as $skyscraper) {
    echo "<li><a href='$skyscraper->url'>$skyscraper->title</a></li>";
}

Related


Comments

  • Posted by pwired on Aug 29, 2013 10:26 AM

    Great work Soma. This will also make more people find their way to processwire. I like the contrasting colors, layout and fonts you used for a clear and clean presentation.

  • Posted by onjegolders on Aug 29, 2013 9:06 AM

    This is great Soma, any chance of matching the IP board usernames with this so that we don't have to fill in name/details on comments (makes it a bit more easy to build up comments) No big deal though. This implementation looks great!

  • Posted by kongondo on Aug 16, 2013 11:56 AM

    Brilliant! Thanks Soma!

  • Posted by soma on Aug 16, 2013 10:07 AM

    Thanks kongondo for the feedback, yeah I implemented a keyword parser to the description text to autolink them. Also added a related links. Fun

  • Posted by kongondo on Aug 16, 2013 2:14 AM

    It is great! With time, perhaps some cross-referencing could be added? E.g., above, "PageArray" should link to the docs about PageArray :). Nice work, thanks!

  • Posted by soma on Aug 16, 2013 12:47 AM

    This is great!

Post Comment