I've been at this for a few hours already and my brain's starting to feel burnt out. All the dev work I've been doing lately sure isn't helping! So I need a fresh programmer's analytical mind for this.
Anyway, I have three classes and data object types: ClientCategory, Profile and Video. Video and ClientCategory are data objects, Profile is a page. I'm building a category page that features certain profiles and videos (selected via a checkbox in the admin). It displays only one of each at a time. The intention is to display featured video & profile that are within that category.
I have the featured profile one down, all it really is, is this:
$profile = DataObject::get_one("Profile", "ProfilePictureID != 0 AND Featured = true AND ClientCategoryID = $ccid");
This bit of code gets the first profile that matches the current category. Straight forward.
The next part, the video, is a bit harder for me to wrap my head around. The Profile page has a has_one relationship with ClientCategory, however, the video does not. So what I'm trying to build is a function that will search profiles with a particular category id, return them, then search these profiles for videos marked as featured, and then return the first one of them.
Does anybody have any ideas?
SOLVED: Final code posted at end of thread.