This should be relatively easy, BUT for the life of me, I cannot solve it.
I have created a DataObject - called Advert which is under Classifieds template.
And I have created 3 separate pages of Classifieds, ie. Classifieds Page 1, Classifieds Page 2, Classifieds Page 3 -
in the CMS each Classifieds page has a tab with a DOM (manager) with different Adverts (DataOjects).
I can't get the $filter variable to output only Adverts associated with its PARENT page - instead I just get ALL of the adverts display on each one of the Classifieds pages.
here's the code...
<?php
class ClassifiedsPage extends Page
{
static $has_many = array(
'Classifieds' => 'Advert'
);
public function getCMSFields()
{
$fields = parent::getCMSFields();
$manager = new DataObjectManager(
$this,
'Classifieds',
'Advert'
);
$fields->addFieldToTab("Root.Content.Classifieds", $manager);
return $fields;
}
}
class ClassifiedsPage_Controller extends Page_Controller
{
function AllClassifieds()
{
$classifieds = DataObject::get_one("ClassifiedsPage");
return ($classifieds) ? DataObject::get(
$obj = "Advert",
$filter = "",
$sort = "Created DESC",
$join = "",
$limit = ""
) : false;
//$classifieds = DataObject::get($obj, $filter, $sort, $join, $limit);
}
}
?>