您好,我正在研究 Yii 1x 框架。我使用了提到的方法 http://www.apurbadebnath.com/blog/yii-how-to-set-up-page-title-and-meta-description-from-yii-controller/ 在以下链接中。
我面临的问题是我 View 中的标题标 checkout 现在我使用 Yii Controller 注册的元标签之后。从 SEO 的角度来看,在元标记(desc 和关键字)之前获得标题很重要。请问有没有办法解决以上问题。
提前致谢。
最佳答案
这是设计使然。来自文档:
Registers a meta tag that will be inserted in the head section (right before the title element) of the resulting page.
我建议在父 Controller 中将所有必要的元参数声明为变量,并在子 Controller 中适本地设置它们。
$this->meta_param_1 = 'test';
$this->meta_param_2 = 'test';
然后像这样在您的布局中设置它们:
<title><?php echo CHtml::encode($this->pageTitle); ?></title>
<meta name="meta_param_1" content="<?php echo CHtml::encode($this->meta_param_1); ?>" />
<meta name="meta_param_2" content="<?php echo CHtml::encode($this->meta_param_2); ?>" />
关于php - 使用 Yii 框架时标题和元标记的顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33095653/