// get category id, if any //$categoryid = News::GetCategoryId(); $settings = Typeframe::CurrentPage()->settings(); // set category id in template //$pm->setVariable('categoryid', $settings['categoryid']); // get articles; limit to this category and valid publication date $articles = new Model_News_Article(); $categories = new Model_News_Category(); if (isset($settings['categoryid']) && is_array($settings['categoryid']) && count($settings['categoryid']) && !in_array(0, $settings['categoryid'])) { $articles->where('news.categoryid IN ?', $settings['categoryid']); $categories->where('categoryid IN ?', $settings['categoryid']); } $articles->where('pubdate <= ?', Typeframe::Now()); $articles->where('expdate > ? OR expdate = ? OR expdate IS NULL', Typeframe::Now(), '0000-00-00 00:00:00'); $articles->where('status = ?', 'published'); $total = $articles->count(); // set up pagination $perpage = !empty($settings['perpage']) ? $settings['perpage'] : 20; $pag = Pagination::Calculate($total, $perpage); $articles->paginate($pag['page'], $pag['perpage']); $pm->setVariable('pagination', $pag); $settings = Typeframe::CurrentPage()->settings(); // add articles, pagination to template $pm->setVariable('news', $articles); //$pm->setVariableArray(Pagination::Calculate($articles->getTotal(), // $perpage, $articles->getCurrentPage())); // get categories; limit to the given parent category //$categories = new News_Category_Factory(); $categories = new Model_News_Category(); //if ($categoryid) $categories->where('parentid IN ?', $categoryid); //$categories->setParentId($categoryid);