Stefan G. Eberl Posted September 17, 2013 Share Posted September 17, 2013 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: PagesAdd PagePage ListSave SortEdit PageTemplatesFieldsModulesSetupAccessUsersRolesPermissionsEdit pagesDelete pagesMove pages (change parent)View pagesSort child pagesChange templates on pagesAdminister users (role must also have template edit access)User can update profile/passwordLock or unlock a page thanks a lot and regards. stefan Link to comment Share on other sites More sharing options...
Soma Posted September 17, 2013 Share Posted September 17, 2013 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 5 Link to comment Share on other sites More sharing options...
Stefan G. Eberl Posted September 18, 2013 Author Share Posted September 18, 2013 Oh man... thanks a lot. I forgot - I was logged in as admin. damn! thats great.Your code works as admin, too! Best Solution from Soma: $result = $pages->find("has_parent!=2,id!=2|7,status<".Page::statusTrash.",include=all"); Thank you. Best regards Stefan 1 Link to comment Share on other sites More sharing options...
ryan Posted September 22, 2013 Share Posted September 22, 2013 Another option that might work (though not yet tested to compare): $result = $pages->find("template!=admin, has_parent!=2, include=all"); 4 Link to comment Share on other sites More sharing options...
johnnydoe Posted May 10, 2016 Share Posted May 10, 2016 These are great snippets! But I got one more question: how to exclude sites that are unpublished? Link to comment Share on other sites More sharing options...
kongondo Posted May 10, 2016 Share Posted May 10, 2016 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' 1 Link to comment Share on other sites More sharing options...
LostKobrakai Posted May 10, 2016 Share Posted May 10, 2016 If you're using one of those snippets above than exclude them like this: include=all, status!=unpublished 2 Link to comment Share on other sites More sharing options...
johnnydoe Posted May 10, 2016 Share Posted May 10, 2016 @LostKobrakai: Thank you, works like a charm! @kongondo: I want include hidden but published pages. With find, hidden pages are also excluded. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now