wes Posted February 27, 2012 Share Posted February 27, 2012 Hello, So, I have course pages and faculty pages. When I create a new course, I can associate it with 1 or more faculty members by adding them to the course_instructors Page field. When I visit the faculty member's page, I want to view the courses they teach. I'm trying to do this with a selector: // on the faculty member's page $spring_courses = $pages->find('parent=/courses/spring/, course_instructors=$page'); $spring_courses is empty. Just to reiterate, course_instructors is a page field that can have multiple pages in it (multiple instructors). I'm basing my method on this post. Thanks for any suggestions! Link to comment Share on other sites More sharing options...
slkwrm Posted February 27, 2012 Share Posted February 27, 2012 Try to do this (written in browser): $spring_courses = $pages->find('parent=/courses/spring/')->has('course_instructors=$page'); Just realized it's totally wrong. Sorry for disinformation. Please, use Soma's method. Link to comment Share on other sites More sharing options...
Soma Posted February 27, 2012 Share Posted February 27, 2012 I think the "parent=" in the find does only look for direct child pages not on all levels. Not sure though if that's your problem. Apart from that it should work if you use "" instead of '' for the selector string. This is because '' won't get parsed, so using "" will work with the $page var inside. Also not sure if slkwrm's will work in your case.( with "") I always use the get() to go to a certain branch and do a find. $spring_courses = $pages->get("/courses/spring/")->find("course_instructors=$page"); 2 Link to comment Share on other sites More sharing options...
wes Posted February 27, 2012 Author Share Posted February 27, 2012 On 2/27/2012 at 12:34 PM, Soma said: I think the "parent=" in the find does only look for direct child pages not on all levels. Not sure though if that's your problem. Apart from that it should work if you use "" instead of '' for the selector string. This is because '' won't get parsed, so using "" will work with the $page var inside. Also not sure if slkwrm's will work in your case.( with "") I always use the get() to go to a certain branch and do a find. $spring_courses = $pages->get("/courses/spring/")->find("course_instructors=$page"); Ohhh, good catch. Switching the quotes in fact did the trick. Your get/find method works, as well as my original method. Thanks everyone. 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