Bagus
1
Silverstripe Version: 4.*
Question:
Is there a simple way to filter BlogPosts in the controller?
Something like this:
public function getBlogPosts()
{
return BlogPost::get()->filter([
'ParentID' => $blog->ID,
'Category' => 'Some category']);
}
Tim
2
Yes… something like that
What results are you getting when you try? Are they not what you’re expecting?
Bagus
3
Well yes and no
I get "Unknown column 'Category' in 'where clause'"
error.
Bagus
4
I think I got it:
return BlogPost::get()->filter([
'ParentID' => $blog->ID,
'Categories.Title' => 'Title of my category']);
I didn’t know I could use this in filter
1 Like