opalepatrick Posted May 8, 2014 Posted May 8, 2014 Hi, I am trying to do this: if ($page->parents->has("by-usage")) { where I know the parent name exists and is called by-usage. Is this correct as I am not getting an error nor an expected result? Thanks for the help.
renobird Posted May 8, 2014 Posted May 8, 2014 opalepatrick, $page->parents returns a pageArray, so you need to check for the id instead of the name. Me thinks. [deleted code] Scratch that, there is some fancier stuff that goes here there than I remembered. has() needs a page object. $parentPage = $pages->get("/path/to/parent/"); if ($page->parents->has($parentPage)){ 1
diogo Posted May 8, 2014 Posted May 8, 2014 I don't think that works. You can use any selector though so this should work: if ($page->parents->has("name=by-usage")) { This is also fine: if ($page->find("name=by-usage")->count()) { 6
renobird Posted May 8, 2014 Posted May 8, 2014 Nice one diogo, I completely forgot you can use selectors.
opalepatrick Posted May 8, 2014 Author Posted May 8, 2014 Thanks renobird and diogo. That worked a treat! I spent far too long on that 1
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