Hello, I'm trying to select doctor pages associated with locations. Within this doctor page I have multiple pages selector (which are location pages) because doctors can work at many. When viewing a single location page, I'd like to loop through those doctors at that location, which is this $page.
How can I achieve this because mine isn't working?
$doctors = $pages->find('template=staff-page,parent=1018,locations=$page');
foreach($doctors as $doc) {
echo "<h4>$doc->title</h4>";
}
I guess I answered my own question. Is this an acceptable way to achieve?
foreach($doctors as $doc) {
foreach($doc->locations as $loc) {
if($loc->title == $page->title) {
echo "<h4>$doc->title</h4>";
echo "<h5>$loc->title</h5>";
}
}
}