Jump to content

how-to get a list of all pages (recursiv) without admin-pages?


Stefan G. Eberl
 Share

Recommended Posts

hi @ all.

how can i get a list/array of all pages (recursiv)

- but without admin-pages

- incluing all sub-pages?

pages i won't get:
for example:

Pages
Add Page
Page List
Save Sort
Edit Page
Templates
Fields
Modules
Setup
Access
Users
Roles
Permissions
Edit pages
Delete pages
Move pages (change parent)
View pages
Sort child pages
Change templates on pages
Administer users (role must also have template edit access)
User can update profile/password
Lock or unlock a page

thanks a lot and regards.

stefan

Link to comment
Share on other sites

This turns out more complex than it seems, but it is usually something not used that often or ever at all. Even with my experience took some time to get all pages, unpublished , published, hidden, not in trash and not under admin. This is with superuser logged in as I think as editor or guest user you won't get pages from trash anyway.

But something like this is needed currently :) Unless I'm missing something.

$pa = $pages->find("has_parent!=2,id!=2|7,status<".Page::statusTrash.",include=all");

foreach ($pa as $p) {
  echo "<li>$p->path</li>";
} 

Note that as soon as you got a few hundred or thousand pages you will get a problem  ;)

Edit:

id = 2 // is the /processwire/ admin parent

id = 7 // is the trash

include=all // to get all pages unpublished and hidden

  • Like 5
Link to comment
Share on other sites

  • 2 years later...

These are great snippets! 

But I got one more question: how to exclude sites that are unpublished?

By default, ProcessWire only returns published pages...so, exclusion of unpublished pages is already done within a 'find'

  • Like 1
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...