Hans0L0 Posted August 18, 2018 Share Posted August 18, 2018 Hi, I'm new to Processwire and it's been quite a while since my last programming experiences with PHP. Currently I'm trying to read through the different site profile versions and stumbled over some code construct in the '_main.php' of the intermediate profile which I've never seen before: foreach($homepage->and($homepage->children) as $item) To me, it looks like 'and()' is used as a method of object '$homepage' in this case but in combination with the 'foreach'-part I don't understand what exactly is happening here and why this is possible. I hope that someone can explain it to me on a basic level :) Thanks in advance Hans Link to comment Share on other sites More sharing options...
dragan Posted August 18, 2018 Share Posted August 18, 2018 The second-last example explains it quite well: // generate breadcrumb trail that includes current page foreach($page->parents->and($page) as $item) { echo "<a href='$item->url'>$item->title</a> / "; } 2 Link to comment Share on other sites More sharing options...
Hans0L0 Posted August 18, 2018 Author Share Posted August 18, 2018 Ok, thank you for the fast reply! :) Link to comment Share on other sites More sharing options...
bernhard Posted August 19, 2018 Share Posted August 19, 2018 welcome to the forum @Hans0L0 I've setup a custom search shortcut "api" in my browser so i can just type "api and" and will get this result: You'll then get to the api docs quickly: https://processwire.com/api/ref/wirearray/and/ 2 Link to comment Share on other sites More sharing options...
Hans0L0 Posted August 25, 2018 Author Share Posted August 25, 2018 Hi @bernhard, that's another good hint. Thanks for that! :) 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