zendframework中如何根据不同的页面设置不同的SEO
头部文件中:
<title>
<?php // show_bug((array)$this->placeholder('html_title'));
$title=(array)$this->placeholder('html_title');
if (empty($title)) {
echo $this->seed_Setting['www_html_title'];//seed_Setting是一个全局变量
}else
{echo $this->placeholder('html_title');};
?>
</title>
<meta name="keywords" content="<?php
$keywords=(array)$this->placeholder('html_keywords');
if (empty($keywords)) {
echo $this->seed_Setting['www_html_keywords'];
}else
{echo $this->placeholder('html_keywords');}; ?>" />
<meta name="description" content="<?php
$description=(array)$this->placeholder('html_description');
if (empty($description)) {
echo $this->seed_Setting['www_html_description'];
}else
{echo $this->placeholder('html_description');}; ?>" />
其他的HTML文件 引入头部文件之前:
<?php
$this->placeholder('html_title')->set($this->html_title);
$this->placeholder('html_keywords')->set($this->html_keywords);
$this->placeholder('html_description')->set($this->html_description);
?>
<?php echo $this->render('header.phtml');?>
controller文件:
//为文章添加SEO
$newsAll = $news->fetchNews(array('news_id'=>$news_id),'*',array('add_time DESC'));
$this->view->html_title=$newsAll['html_title'];
$this->view->html_keywords=$newsAll['html_keywords'];
$this->view->html_description=$newsAll['html_description'];
至此就可以完成不同页面的SEO,设置不同的值了

浙公网安备 33010602011771号