If you can, getting data using the built in ORM for object relationships might be useful.
e.g.
PropertyPage.php:
class PropertyPage extends Page {
public static $has_many = array(
'Openhouses' => 'Openhouse'
);
// This overloads the default relationship getter with a custom date query
// See DataObject::getComponents() for the parameters you can provide to the relationship getter
public function getOpenhouses() {
return $this->getComponents('Openhouses', 'Date = '12/12/2000', 'Date DESC');
}
}
Openhouse.php:
class Openhouse extends DataObject {
public static $has_one = array(
'PropertyPage' => 'PropertyPage'
);
}
Code above is simplified for brevity, I've also made an assumption Openhouse is a DataObject subclass, but it could be a Page subclass also. Also, the relationship between PropertyPage and Openhouse could be a many-to-many relationship, but the above could be altered to fit that also, using many_many and belongs_many_many instead of has_many and has_one.
Essentially the key is having getOpenhouses() on PropertyPage which overrides the default relationship getter, and uses the ORM instead to filter the results, the second parameter is a WHERE clause on getComponents() or getManyManyComponents() if it's a many-to-many relationship.
Using the above, <% control Openhouses %> would become available in the PropertyPage template, and this lists all related Openhouse objects that are related to that PropertyPage, but instead it's filtered by the getOpenhouses() defined on PropertyPage.
Hope this helps.
Sean