Jump to content

All Pages


globi
 Share

Recommended Posts

Hallo!

I'm trying to retrieve all the pages in an array, but I can't find the proper selector.
What's the way to get all the pages, no matter of their names, parent, templates, etc.?

Best regards,
Mick

Link to comment
Share on other sites

erm

foreach($pages->find() as $p) {
    echo "<p>{$p->url}</p>";
}
 

returns nothing... but

foreach($pages->find("*") as $p) {
    echo "<p>{$p->url}</p>";
}
returns all.
 
While...
foreach($pages->find("has_parent!=2") as $p) {
    echo "<p>{$p->url}</p>";
}
would exclude pages under "/processwire/" admin pages.
 
But maybe something also some restriction to template(s) would be good.
foreach($pages->find("template=basic-page|article|news") as $p) {
    echo "<p>{$p->url}</p>";
}
  • Like 3
Link to comment
Share on other sites

$pages->find("*")

That's it. Thanks!

Maybe I've forgotten something, but I don't know why that works. I don't think we have any code specifically looking for a wildcard like that. Chances are its getting filtered out to nothing, but getting far enough in the Selector engine to let the query proceed... kind of like an id>0 selector. 

  • Like 1
Link to comment
Share on other sites

Maybe I've forgotten something, but I don't know why that works. I don't think we have any code specifically looking for a wildcard like that. Chances are its getting filtered out to nothing, but getting far enough in the Selector engine to let the query proceed... kind of like an id>0 selector. 

Is this the part you're looking for?:

wire\core\Sanitizer.php:
  427  		// disallow some characters in selector values
  428  		// @todo technically we only need to disallow at begin/end of string
  429: 		$value = str_replace(array('*', '~', '`', '$', '^', '+', '|', '<', '>', '!', '='), ' ', $value);
  • Like 1
Link to comment
Share on other sites

That could be the case that "*" is just being considered a selector value, and is being filtered out. Though without following the path through the code, it's also that the selector engine sees an operator character with no field and no value, and thus excludes it from the equation. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...