adrian Posted March 9, 2013 Share Posted March 9, 2013 I was hoping there would be a selector called rootParent. I ended up getting all the pages that matched the rest of my selectors and then filtered them out with $page->rootParent in the foreach loop. This isn't a bad option, but causes problems when using limit in the initial selector set. Anyway, just wondering if there is a better way to do this, or if rootParent could be added as a selector. Maybe the template selector is a cleaner solution in most cases? Link to comment Share on other sites More sharing options...
apeisa Posted March 9, 2013 Share Posted March 9, 2013 Are you after something like this: $pages->get("/desired-rootparent/")->find("other selectors")? Link to comment Share on other sites More sharing options...
adrian Posted March 9, 2013 Author Share Posted March 9, 2013 Yep, that would do it. I am still not quite always thinking in PW yet I was initially setting it up as: $latest = $pages->find("rootParent=xxx, sort=-modified, limit=10"), but in reality I want to specify more than one rootParent, so I would need the ability for "get" or "find"ing more than one anyway, which isn't possible - correct? Link to comment Share on other sites More sharing options...
Soma Posted March 9, 2013 Share Posted March 9, 2013 Use maybe has_parent=id|id2 I think that should work Link to comment Share on other sites More sharing options...
adrian Posted March 10, 2013 Author Share Posted March 10, 2013 Thanks Soma, but using that in a find gives me array to string conversion errors. It does seem like has_parent can only be used with one page: http://processwire.com/talk/topic/1921-has-parent-issue/ Link to comment Share on other sites More sharing options...
Pete Posted March 10, 2013 Share Posted March 10, 2013 Replace id and id2 with actual numbers in Soma's example. You can get the page numbers in the admin by clicking on a page name and clicking the edit button - their ID will be clear in the URL. Link to comment Share on other sites More sharing options...
adrian Posted March 11, 2013 Author Share Posted March 11, 2013 Hey Pete - yep, I was using proper page ID numbers. I actually just tested out a has_parent using the selector test tool, with multiple pipe-separated page IDs and found that it returns every page in my system including all admin/system pages. Each of the individual page IDs on their own work as expected. Link to comment Share on other sites More sharing options...
Soma Posted March 11, 2013 Share Posted March 11, 2013 Yes sorry, I forgot about it that it works only for 1 parent! Too many things in my head lately However, maybe you can use "parent=id|id2|id3" if it only for direct children pages. Maybe you can tell a little more about what you want to archive, I'm sure there's a good solution. Link to comment Share on other sites More sharing options...
adrian Posted March 11, 2013 Author Share Posted March 11, 2013 Hi Soma - no worries - I know how you feel Basically what I am doing is creating a custom RSS feed and latest activity widget, but I only want to highlight details from certain sections of the site. I have some user edited pages, a user edited glossary, and a forum. These are the three parent pages. I ended up going with this which is a little ugly, but does the trick: $latest = $pages->find("sort=-modified, limit=30"); $items = new PageArray; foreach($latest as $lpage){ if(($lpage->rootParent=='1130' || $lpage->rootParent=='1192' || $lpage->rootParent=='1021') && ($lpage!='1130' && $lpage!='1192' && $lpage!='1021')){ $items->add($lpage); } } I actually might end up switching to a template selector as I think this will be cleaner and still achieve what I need. 1 Link to comment Share on other sites More sharing options...
gebeer Posted November 25, 2021 Share Posted November 25, 2021 @adrianrevviving this old thread because I would need the rootparent selector, too. Have any of you ever had the need for this kind of selector? Just asking here before filing a feature request. Link to comment Share on other sites More sharing options...
adrian Posted November 25, 2021 Author Share Posted November 25, 2021 It looks like has_parent now supports multiple pages and I think it has served all my needs around this. What can't it do in your use case? 4 Link to comment Share on other sites More sharing options...
gebeer Posted November 25, 2021 Share Posted November 25, 2021 41 minutes ago, adrian said: It looks like has_parent now supports multiple pages and I think it has served all my needs around this. What can't it do in your use case? Totally did not think of that one. Thanks a ton! 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