本文整理汇总了PHP中Meta::links方法的典型用法代码示例。如果您正苦于以下问题:PHP Meta::links方法的具体用法?PHP Meta::links怎么用?PHP Meta::links使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Meta
的用法示例。
在下文中一共展示了Meta::links方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_view
/**
* 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'));
}
}
示例2:
<!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]-->
示例3: action_tag
/**
* 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));
}
}
示例4: _set_default_meta_links
/**
* 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);
}
}
}
示例5: remove_links
/**
* 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]);
}