21287 Posts in 5733 Topics by 2602 members
General Questions
SilverStripe Forums » General Questions » [SOLVED] Finding and filtering multiple related data objects
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | Next > | |
| Author | Topic: | 1754 Views |
-
Re: [SOLVED] Finding and filtering multiple related data objects

4 November 2010 at 9:16pm
Sorry, I wasn't aware that Profile and Videos has a relationship.
/C
-
Re: [SOLVED] Finding and filtering multiple related data objects

4 November 2010 at 10:14pm
Hi Ryan,
Have you debugged what is coming before?
print_r($vids); die(); //see what values 'Featured' has before the find
$vids->sort('Created', 'DESC');
$videos = $vids->find('Featured', 'true');Barry
-
Re: [SOLVED] Finding and filtering multiple related data objects

5 November 2010 at 8:10am
Hi Swaiba, yea if you notice one of my previous posts, it said I tried one line earlier and it returned all the dataobjects available. It's the find() function that doesn't work. =(
-
Re: [SOLVED] Finding and filtering multiple related data objects

5 November 2010 at 8:45am
doh! I guess what I meant to ask is what is the data... the find function looks simple so it'd help to see the data... btw I wrap my output buffering around my print_r's so I can log 'em if it helps...
ob_start();
print_r($arr);
$var = ob_get_contents();
ob_end_clean(); -
Re: [SOLVED] Finding and filtering multiple related data objects

5 November 2010 at 8:50am
The data displayed is a DataObjectSet of the DataObjects returned by this:
$vids = new DataObjectSet();
foreach($videoIDs as $id) {
$record = DataObject::get_by_id("Video", $id);
$vids->push(new ArrayData($record));
}
$vids->sort('Created', 'DESC'); -
Re: [SOLVED] Finding and filtering multiple related data objects

5 November 2010 at 8:53am
Actually, that is not how I've ever done it...
instead of...
$vids->push(new ArrayData($record));
i use...
$vids->push($record);
...does that help?
-
Re: [SOLVED] Finding and filtering multiple related data objects

5 November 2010 at 9:01am
I'll give it a try. That's not how the SS documentation for DataObjectSet says how to do it though... lol, these guys need to update the documentation. =)
-
Re: [SOLVED] Finding and filtering multiple related data objects

5 November 2010 at 10:07am Last edited: 6 November 2010 10:00pm
well code is often the best documentation
throughout the code ss creates DataObjectSets with $dos->push($do) or $dos->push(new ArrayData(array(...))), what you've got is $dos->push(new ArrayData($do)) where ArrayData and DataObject are both similar sorts of classes, not like when ss creates a ArradyData with an array of values.
EDIT on this it looks like arraydata takes both as arguments to it's constructor and it may not make any difference...
| 1754 Views | ||
| Go to Top | Next > |



