Hi, I am new to the Silverstripe way so this might be totally off the wall but...
I am trying to select and filter pages (SOURCE) based on a has_many property they have from a sibling page (QUERY) e.g.
SOURCE:
class HelpAnswer extends Page {
private static $db = array();
private static $has_many = array(
'Taxonomy' => 'CategoryTag'
);
}
class CategoryTag extends DataObject {
static $db = array(
'Category' => 'Varchar(50)',
'Tag' => 'Varchar(15)'
);
public static $has_one = array(
'HelpAnswer' => 'HelpAnswer'
);
QUERY:
class HelpTopic extends Page {
static $db = array(
'Category' => 'Varchar(50)'
);
}
class HelpTopic_Controller extends Page_Controller {
public function getAnswers($tag) {
XXXXXXX
}
}
I have tried things like the following but I haven't yet been able to get enough access across the dataObjects to pull the query together. Ultimately I am looking for the syntax magic I can sprinkle in at XXXXXXX in order to select all the Help_Answer pages that have the specified 'Category'. Further to this I would also like to group them by 'Tag'.
$answers = $parent->Children(); // Works, but no filtering
$answers = $parent->Children()->filter('ClassName','HelpAnswer'); // Works, but not enough filtering
$answers = $parent->Children()->filter('Category', $this->Category); // Returns Records, not to requirement
$answers = $parent->Children()->filter('Taxonomy.Category', $this->Category); // Error
$answers = $parent->Children()->filter('ClassName','HelpAnswer')->filter('Taxonomy.Category', $this->Category); // Error