theo Posted March 4, 2018 Share Posted March 4, 2018 Hello Can anybody explain, why the result of the selector "has_parent=1" includes 'home'? $homes=$pages->findIDs("has_parent=1"); echo $pages->get($homes[0])->name; //returns 'home' I would expect that 'home' is not a parent of itself. Thank you. Link to comment Share on other sites More sharing options...
ottogal Posted March 4, 2018 Share Posted March 4, 2018 No idea - just the observation that the result is the same when you use $pages->find() with the $options parameter like this: $options = array('findIDs'=>1); $homes=$pages->find("has_parent=1", $options); echo $pages->get($homes[0])->name; //returns 'home' 1 Link to comment Share on other sites More sharing options...
alxndre Posted March 5, 2018 Share Posted March 5, 2018 Not sure as well, but maybe has something to do with '/' being the only saved page with a NullPage as a parent? echo print_r($pages->get('/')); // result // ProcessWire\NullPage Object ( ... ) And in the database, home's parent_id is 0, and it does not have an entry in pages_parents. Upon further digging, I also found that home is the only result when querying for "has_parent!=1", and it is hard-coded. Anyway, if you require home to not be in the result, maybe just exclude it from the query? $childrenOfHome = $pages->find("has_parent=1, id!=1"); 1 1 Link to comment Share on other sites More sharing options...
theo Posted March 5, 2018 Author Share Posted March 5, 2018 @alxndre Sure it is not really a problem, once you know how it works. For my case this does what I want: $pages->find("id!=1,has_parent!=2"); Meaning: all, except home and everything under admin (For logged in admins). But still, such little uncertainties can diminish confidence in the system. Link to comment Share on other sites More sharing options...
Zeka Posted March 5, 2018 Share Posted March 5, 2018 @theo I think that is something that should be reported. Could you open an issue on Github, so Ryan could comment is it intended behavior or a bug? 1 Link to comment Share on other sites More sharing options...
kongondo Posted March 5, 2018 Share Posted March 5, 2018 (edited) 29 minutes ago, Zeka said: @theo I think that is something that should be reported. Could you open an issue on Github, so Ryan could comment is it intended behavior or a bug? This has always been the case as far as I can remember. Similar to rootParent of home: $h = $pages->get(1); echo $h->rootParent->id;// outputs 1 You'd think home shouldn't have a root parent, but it does. I think both were intended, but let's see what @ryan says. Edited March 5, 2018 by kongondo 1 Link to comment Share on other sites More sharing options...
theo Posted March 5, 2018 Author Share Posted March 5, 2018 @kongondo Does ryan usually read the forum, when you call him with @? Link to comment Share on other sites More sharing options...
szabesz Posted March 5, 2018 Share Posted March 5, 2018 5 hours ago, theo said: Does ryan usually read the forum, when you call him with @? These days rarely but one never knows 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