cb2004 Posted August 26, 2021 Share Posted August 26, 2021 This is always an age old issue for me to get my head around, I am not sure if this was a feature added recently, maybe I had a dream that I read the blog post. Essentially I set some sites up that can go as deep as the client would like, but when I am on a page, I want to search for anything below that. For example: Home Page (I want to find all events beneath me) - Event - Page -- Event -- Page --- Event Page - Event - Page -- Event -- Page --- Event Now if this isn't possible with 1 find then let me know, I can move on and work around it. Link to comment Share on other sites More sharing options...
elabx Posted August 26, 2021 Share Posted August 26, 2021 Have you tried: $page->find('template=event'); Should return all descendants of the current page. 2 Link to comment Share on other sites More sharing options...
Jan Romero Posted August 26, 2021 Share Posted August 26, 2021 More generally, there is a selector for this exact thing: has_parent https://processwire.com/docs/selectors/#finding2 2 Link to comment Share on other sites More sharing options...
cb2004 Posted August 26, 2021 Author Share Posted August 26, 2021 Amazing, both do exactly what I need. Any speed differences would we say? Link to comment Share on other sites More sharing options...
elabx Posted August 26, 2021 Share Posted August 26, 2021 find() in the end uses has_parent, so I don't think there's much difference. https://github.com/processwire/processwire/blob/master/wire/core/Page.php#L2222 1 Link to comment Share on other sites More sharing options...
cb2004 Posted August 26, 2021 Author Share Posted August 26, 2021 Cheers @elabx. I hope you are keeping well. 1 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