You're right it doesn't make any difference. I tried your suggestion of using $do->push($record) instead of $do->push(new ArrayData($record)) but no change. I'm definitely sure it's got something to do with find()
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Go to End
- Previous 10 entries
- 1
- 2
- Page 33(current)
I figured out a solution without even using find().
Final code:
public function FeaturedVideo() {
$vid = null;
if($ClassName = "ProfileHolder" && $cat = $this->urlParams['ID']) {
$cat = str_replace('-', ' ', $cat);
$cat = ucwords($cat);
$ccid = DataObject::get_one("ClientCategory", "Name = '{$cat}'")->ID;
$profiles = DataObject::get("Profile", "ClientCategoryID = $ccid");
$videoIDs = array();
foreach($profiles as $profile => $data) {
foreach($data->Videos() as $video) {
$videoIDs[] = $video->ID;
}
}
$vids = new DataObjectSet();
foreach($videoIDs as $id) {
$record = DataObject::get_by_id("Video", $id);
if($record->Featured = true) {
$vids->push($record);
}
}
$vids->sort('LastEdited', 'DESC');
$vid = $vids->First();
}
if($vid) {
return DataObject::get_by_id("Video", $vid->ID);
} else
return DataObject::get_one("Video", "Featured = true");
}
Go to Top
- Previous 10 entries
- 1
- 2
- Page 33(current)