Jump to content

selecting from a [multi] Page field?


wes
 Share

Recommended Posts

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

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

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");
  • Like 2
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...