本文整理汇总了PHP中view::setMetaKeywords方法的典型用法代码示例。如果您正苦于以下问题:PHP view::setMetaKeywords方法的具体用法?PHP view::setMetaKeywords怎么用?PHP view::setMetaKeywords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类view
的用法示例。
在下文中一共展示了view::setMetaKeywords方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
public function set($plugin, $keyword, $replace = array(), $pageTitle = true)
{
if (!($data = $this->cache->item('core_meta_tags_' . $plugin . '_' . session::item('language')))) {
$data = array();
$result = $this->db->query("SELECT * FROM `:prefix:core_meta_tags` WHERE `plugin`=?", array($plugin))->result();
foreach ($result as $tags) {
$data[$tags['keyword']]['title'] = $tags['meta_title_' . session::item('language')];
$data[$tags['keyword']]['description'] = $tags['meta_description_' . session::item('language')];
$data[$tags['keyword']]['keywords'] = $tags['meta_keywords_' . session::item('language')];
}
$this->cache->set('core_meta_tags_' . $plugin . '_' . session::item('language'), $data, 60 * 60 * 24 * 30);
}
foreach ($replace as $section => $array) {
foreach ($array as $k => $v) {
$k = '[' . $section . '.' . $k . ']';
if (is_array($v)) {
$v = count($v) == 1 ? current($v) : implode(',', $v);
}
$data[$keyword]['title'] = utf8::str_replace($k, $v, $data[$keyword]['title']);
$data[$keyword]['description'] = utf8::str_replace($k, $v, $data[$keyword]['description']);
$data[$keyword]['keywords'] = utf8::str_replace($k, $v, $data[$keyword]['keywords']);
}
}
if (isset($data[$keyword])) {
if ($pageTitle) {
view::setTitle($data[$keyword]['title']);
} else {
view::setMetaTitle($data[$keyword]['title']);
}
view::setMetaDescription($data[$keyword]['description']);
view::setMetaKeywords($data[$keyword]['keywords']);
}
}
示例2: view
public function view()
{
// Get URI vars
$newsID = (int) uri::segment(3);
// Get news entry
if (!$newsID || !($news = $this->news_model->getEntry($newsID, 'in_view')) || !$news['active']) {
error::show404();
}
// Do we have views enabled?
if (config::item('news_views', 'news')) {
// Update views counter
$this->news_model->updateViews($newsID);
}
// Load ratings
if (config::item('news_rating', 'news') == 'stars') {
// Load votes model
loader::model('comments/votes');
// Get votes
$news['user_vote'] = $this->votes_model->getVote('news', $newsID);
} elseif (config::item('news_rating', 'news') == 'likes') {
// Load likes model
loader::model('comments/likes');
// Get likes
$news['user_vote'] = $this->likes_model->getLike('news', $newsID);
}
// Assign vars
view::assign(array('newsID' => $newsID, 'news' => $news));
// Set title
view::setTitle($news['data_title']);
// Set meta tags
view::setMetaDescription($news['data_meta_description']);
view::setMetaKeywords($news['data_meta_keywords']);
// Load view
view::load('news/view');
}
示例3: index
public function index()
{
// Get URI vars
if (!($location = uri::getURI())) {
$this->home();
return;
} elseif ($location == 'site/offline') {
$this->offline();
return;
}
// Get page
if (!($page = $this->pages_model->getPage($location, 'in_view', array('replace' => true))) || !session::permission('site_access_cp', 'system') && !$page['active']) {
error::show404();
}
// Set page ID
$pageID = $page['page_id'];
// Do we have views enabled?
if (config::item('page_views', 'pages')) {
// Update views counter
$this->pages_model->updateViews($pageID);
}
// Load ratings
if (config::item('page_rating', 'pages') == 'stars') {
// Load votes model
loader::model('comments/votes');
// Get votes
$page['user_vote'] = $this->votes_model->getVote('page', $pageID);
} elseif (config::item('page_rating', 'pages') == 'likes') {
// Load likes model
loader::model('comments/likes');
// Get likes
$page['user_vote'] = $this->likes_model->getLike('page', $pageID);
}
// Assign vars
view::assign(array('pageID' => $pageID, 'page' => $page));
// Set title
view::setTitle($page['data_title']);
// Set meta tags
view::setMetaDescription($page['data_meta_description']);
view::setMetaKeywords($page['data_meta_keywords']);
// Do we need to build a trail?
if ($page['trail']) {
if ($page['parent_id']) {
$parents = $this->pages_model->getParents($page['parent_id']);
foreach ($parents as $parent) {
view::setTrail($parent['location'], $parent['data_title']);
}
if ($parents) {
// Set trail
view::setTrail($location, $page['data_title']);
}
} else {
// Set trail
view::setTrail($page['location'], $page['data_title']);
}
}
// Do we have a custom file name?
if ($page['file_name']) {
// Load custom view
view::load($page['file_name']);
} else {
// Load default view
view::load('pages/view');
}
}