<?php /* 29 december 2010: cleanup while trying to add status field to typef_news table; rewrote to use news categories class 3 january 2011: DAOFactory, not DAO_Factory; setCategoryId now static 28 march 2011: merged in HL code 29 march 2011: added page title, header */ // define some handy shortcuts to save typing $settings = Typeframe::CurrentPage()->settings(); if (Typeframe::CurrentPage()->pathInfo()) { Typeframe::IncludeScript('/news/categories/view.php'); return; } if (is_array($settings['categoryid']) && !in_array(0, $settings['categoryid']) && 1 == count($settings['categoryid'])) { Typeframe::Redirect('Redirecting to category listing...', Typeframe::CurrentPage()->applicationUri() . 'categories/' . $settings['categoryid'][0]); return; } // create news category object $categories = News_Category::DAOFactory(); // limit to a particular category id News::SetCategoryId($categories, @$settings['categoryid']); // add categories to template $pm->setVariable('categories', $categories); // add page title and header to template $title = News::GetTitle(); $pm->setVariable('page_title', $title); $pm->setVariable('page_header', $title);
} // create news category object $category = new News_Category($categoryid); // redirect if category id is invalid if (!$category->exists()) { Typeframe::Redirect('Invalid category specified.', Typeframe::CurrentPage()->applicationUri(), 1); return; } // determine if there are 0 or more than 1 categories; add flag to template if (in_array(0, $settings['categoryid']) || count($settings['categoryid']) > 1) { $pm->setVariable('multicats', true); } // add category name, id, and object to template $pm->setVariable('categoryname', $category->get('categoryname')); $pm->setVariable('categoryid', $category->get('categoryid')); $pm->setVariable('category', $category); // create news article object $articles = News_Article::DAOFactory(); // filter by category id News::SetCategoryId($articles, $category->get('categoryid')); // add articles to template $pm->setVariable('news', $articles); // get comment types $comment_types = CommentType::DAOFactory(); $comment_types->select()->order('name'); // add comment types to template $pm->setVariable('comment_types', $comment_types); // add page title and header to template $title = News::GetTitle(); $pm->setVariable('page_title', $title); $pm->setVariable('page_header', $title);
<?php /* 29 december 2010: cleanup while trying to add status field to typef_news table; rewrote to use news tag class 3 january 2011: DAOFactory, not DAO_Factory; setCategoryId now static 28 march 2011: merged in code from HL 29 march 2011: added page title, header */ // define some handy shortcuts to save typing $settings = Typeframe::CurrentPage()->settings(); // create news tag object $tags = News_Tag::DAOFactory(); // inner join on the news article table $tags->select()->innerJoin('#__news', '#__news.newsid = #__news_tag.newsid'); // add the count of news articles to the result $tags->select()->field('COUNT(#__news_tag.newsid) AS articles'); // limit to a particular category id News::SetCategoryId($tags, @$settings['categoryid']); // group and sort by tag name $tags->select()->group('tag'); $tags->select()->order('tag'); // add tags to template $pm->setVariable('tags', $tags); // add page title and header to template $title = News::GetTitle(); $pm->setVariable('page_title', $title); $pm->setVariable('page_header', $title);
$settings = Typeframe::CurrentPage()->settings(); // get tag $tag = urldecode(Typeframe::CurrentPage()->pathInfo()); if ('' == $tag) { $tag = @$_REQUEST['tag']; } // validate tag if (!$tag) { Typeframe::Redirect('Invalid tag specified.', Typeframe::CurrentPage()->applicationUri(), 1); return; } // add tag to template $pm->setVariable('tag', $tag); // create news article object $articles = News_Article::DAOFactory(); // limit to a particular category id News::SetCategoryId($articles, @$settings['categoryid']); // limit to a particular tag $articles->select()->innerJoin('#__news_tag AS nt', '#__news.newsid = nt.newsid'); $articles->select()->where('nt.tag = ?', $tag); // add articles to template $pm->setVariable('news', $articles); // get comment types $comment_types = CommentType::DAOFactory(); $comment_types->select()->order('name'); // add comment types to template $pm->setVariable('comment_types', $comment_types); // add page title and header to template $title = News::GetTitle(); $pm->setVariable('page_title', $title); $pm->setVariable('page_header', $title);