Hello guys,
Need a little help getting some IDs from a relation table.
The below code is what i use for a home page. In the administration you can now select multible pages, and the IDs are saved to the relation table "ForsidePage_PreviewList".
i need to use the IDs from this table in my filter in "ForsidePage_Controller" in the function "showPreviews", and not the hardcoded ...".ID IN (8,9,10)" ...
How can this be done?
class ForsidePage extends Page {
static $db = array();
static $has_one = array();
public static $many_many = array(
'PreviewList' => 'SiteTree'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Previews', new TreeMultiselectField( 'PreviewList', 'Preview Sites', 'SiteTree'));
return $fields;
}
}
class ForsidePage_Controller extends Page_Controller {
function showPreviews() {
$myIds = "";// Query to get IDs from the relation table
$records = DataObject::get("WithPreviewPage", "`WithPreviewPage`.ID IN (8,9,10)");
return ($records);
}
}