/** * List of pages (blogs/posts/etc.) with a specific tag * * @throws HTTP_Exception_404 * * @uses Log::add * @uses Text::ucfirst * @uses ACL::check * @uses Meta::links * @uses URL::canonical * @uses Route::url */ public function action_view() { $id = (int) $this->request->param('id', 0); $tag = ORM::factory('tag', $id); if (!$tag->loaded()) { throw HTTP_Exception::factory(404, 'Tag :tag not found!', array(':tag' => $id)); } $this->title = __(':title', array(':title' => Text::ucfirst($tag->name))); $view = View::factory('tag/view')->set('teaser', TRUE)->bind('pagination', $pagination)->bind('posts', $posts); $posts = $tag->posts; if (!ACL::check('administer tags') and !ACL::check('administer content')) { $posts->where('status', '=', 'publish'); } $total = $posts->reset(FALSE)->count_all(); if ($total == 0) { Log::info('No posts found.'); $this->response->body(View::factory('page/none')); return; } $pagination = Pagination::factory(array('current_page' => array('source' => 'cms', 'key' => 'page'), 'total_items' => $total, 'items_per_page' => 15, 'uri' => $tag->url)); $posts = $posts->order_by('created', 'DESC')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all(); $this->response->body($view); // Set the canonical and shortlink for search engines if ($this->auto_render === TRUE) { Meta::links(URL::canonical($tag->url, $pagination), array('rel' => 'canonical')); Meta::links(Route::url('tag', array('action' => 'view', 'id' => $tag->id)), array('rel' => 'shortlink')); } }
<!DOCTYPE html> <html lang="<?php echo $lang; ?> "> <head> <title><?php echo $head_title; ?> </title> <?php echo Meta::tags(); ?> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <?php echo Meta::links(); ?> <?php echo Assets::css(); ?> <link href='//fonts.googleapis.com/css?family=Kaushan+Script' rel='stylesheet' type='text/css'> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <?php echo HTML::script('media/js/html5shiv.js', NULL, TRUE); ?> <?php echo HTML::script('media/js/respond.min.js', NULL, TRUE); ?> <![endif]-->
/** * Tags view * * @throw HTTP_Exception_404 */ public function action_tag() { $config = Config::load('blog'); $id = (int) $this->request->param('id', 0); $tag = ORM::factory('tag', array('id' => $id, 'type' => 'blog')); if (!$tag->loaded()) { throw HTTP_Exception::factory(404, 'Tag ":tag" Not Found', array(':tag' => $id)); } $this->title = __(':title', array(':title' => Text::ucfirst($tag->name))); $view = View::factory('blog/list')->set('teaser', TRUE)->set('config', $config)->bind('rss_link', $rss_link)->bind('pagination', $pagination)->bind('posts', $posts); $posts = $tag->posts; if (!ACL::check('administer tags') and !ACL::check('administer content')) { $posts->where('status', '=', 'publish'); } $total = $posts->reset(FALSE)->count_all(); if ($total == 0) { Log::info('No blogs found.'); $this->response->body(View::factory('blog/none')); return; } $rss_link = Route::get('rss')->uri(array('controller' => 'blog', 'action' => 'tag', 'id' => $tag->id)); $pagination = Pagination::factory(array('current_page' => array('source' => 'cms', 'key' => 'page'), 'total_items' => $total, 'items_per_page' => $config->get('items_per_page', 15), 'uri' => $tag->url)); $posts = $posts->order_by('created', 'DESC')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all(); $this->response->body($view); // Set the canonical and shortlink for search engines if ($this->auto_render) { Meta::links(URL::canonical($tag->url, $pagination), array('rel' => 'canonical')); Meta::links(Route::url('blog', array('action' => 'tag', 'id' => $tag->id), TRUE), array('rel' => 'shortlink')); Meta::links(Route::url('rss', array('controller' => 'blog', 'action' => 'tag', 'id' => $tag->id), TRUE), array('rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => Template::getSiteName() . ' : ' . $tag->name)); } }
/** * Set the default meta links * * Used configuration settings. * * @uses Meta::links * @uses Arr::get */ protected function _set_default_meta_links() { $meta = $this->_config->get('meta', array()); $links = Arr::get($meta, 'links'); if ($links) { foreach ($links as $url => $attributes) { Meta::links($url, $attributes); } } }
/** * Remove a Meta Link, or all * * @param mixed $handle Asset name, or NULL to remove all [Optional] * * @return mixed Empty array or void */ public static function remove_links($handle = NULL) { if (is_null($handle)) { return self::$links = array(); } unset(self::$links[$handle]); }