heldercervantes Posted March 9, 2016 Share Posted March 9, 2016 Hi guys. This is probably real easy and my headache is probably keeping me from thinking straight. Take a products catalogue. The sections have multiple levels, 3 in my case. At the end of each branch there are products. So when I'm at a top section, I want to display all products under all child sections, grandchild sections and so on. How do I reference this in the selector? My only idea is to recursively check every child page down the tree where 'template=section' and slap each of them on the selector, but it seems wrong. Link to comment Share on other sites More sharing options...
BitPoet Posted March 9, 2016 Share Posted March 9, 2016 foreach($grandparent->find("template=product") as $product) { ... } should do the trick. 3 Link to comment Share on other sites More sharing options...
heldercervantes Posted March 9, 2016 Author Share Posted March 9, 2016 OF COURSE! I was searching from $pages and completely forgot you could do it from a $page. Big thanks! Now excuse me while slap myself in the face for a moment. Link to comment Share on other sites More sharing options...
Jan Romero Posted March 9, 2016 Share Posted March 9, 2016 You can do it from $pages as well, using the has_parent selector. It will match up the whole tree, not just the direct parent. I can't believe I actually didn't know $page->find(). Nice one! Link to comment Share on other sites More sharing options...
kongondo Posted March 9, 2016 Share Posted March 9, 2016 Here's an old thread and Ryan's response A quick note for newbies....be careful not to invite the whole family ($page->find()) if you don't have enough room (memory)...you might need to limit numbers 3 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