Hello, I'm hoping someone can help me, I am trying to build a section on a page to display "featured" blog posts. The desired result is that the CMS editor can get a list of blog posts on to a page, based on a category assigned to each blog post. Similar to this question from 2011 where the OP is asking about similar functionality regarding blog tags: http://www.silverstripe.org/community/forums/general-questions/show/17940
I have tried unsuccessfully to use the code suggested in the question from 2011, to see if I can use tags instead of categories. This is the function from that question:
class ArticlePage_Controller extends Page_Controller {
public function featuredBlog($tag) {
return DataObject::get("BlogEntry", "Tag = '{$tag}'");
}
}
returns this error:
[23-Sep-2015 11:42:10] Error at framework/model/MySQLDatabase.php line 598: Couldn't run query:
SELECT DISTINCT count(DISTINCT "SiteTree"."ID") AS "0"
FROM "SiteTree"
LEFT JOIN "BlogPost" ON "BlogPost"."ID" = "SiteTree"."ID"
LEFT JOIN "BlogEntry" ON "BlogEntry"."ID" = "SiteTree"."ID"
WHERE (Tag = '') AND ("SiteTree"."ClassName" IN ('BlogEntry'))
Unknown column 'Tag' in 'where clause' (http://okoru1/projects/project-example-1/)
I am afraid I am not knowledgeable enough in PHP and MySQL to work out how blog categories and blog posts are related, in order to write the correct query function.
Any clues as to how to achieve this would be much appreciated!