I saw the missing Join too, which I added in just as you were posting, but still get the same error.
[User Error] Couldn't run query: SELECT `SiteTree_Live`.*, `Page_Live`.*, `ArticlePage_Live`.*, `SiteTree_Live`.ID, if(`SiteTree_Live`.ClassName,`SiteTree_Live`.ClassName,'SiteTree') AS RecordClassName FROM `SiteTree_Live` LEFT JOIN `Page_Live` ON `Page_Live`.ID = `SiteTree_Live`.ID LEFT JOIN `ArticlePage_Live` ON `ArticlePage_Live`.ID = `SiteTree_Live`.ID WHERE (ArticleCategory) AND (`SiteTree_Live`.ClassName IN ('ArticlePage')) ORDER BY Date DESC LIMIT 4 Unknown column 'ArticleCategory' in 'where clause'
*sighs*
Looks like I have a long night ahead of me still. Don't you hate it when code and you can't figure out why?
Below is my full ArticleHolder.php page
class ArticleHolder extends TwoColumnPage {
static $db = array();
static $has_one = array();
static $default_child = "ArticlePage";
static $allowed_children = array('ArticlePage');
static $icon = "themes/swann/images/treeicons/newsholder";
}
class ArticleHolder_Controller extends Page_Controller {
public function Categories() {
$categories = DataObject::get('ArticleCategory');
return $categories;
}
public function category() {
//$categoryid = $_POST['categoryID'];
$categoryid = $this->URLParams['ID'];
if(empty($categoryid)) {
$category = NULL;
}else{
$category = sprintf('ArticleCategoryID = %d', $categoryid);
}
$categories = $this->Categories();
foreach($categories as $category) {
//array_push($articles, DataObject::get('ArticlePage', $category, 'Date DESC', 4));
array_push($articles, DataObject::get('ArticlePage', $category, 'Date DESC', NULL, 4));
}
return new ArrayData($articles);
}
}