在 CakePHP 3 的正确位置使用元描述
Using Meta Description in the right place CakePHP 3
我正在尝试在 cakephp 3 中使用 meta 标签和描述。到目前为止它工作正常,但我面临的问题是我无法将它放在我的页面中,因为我的 .ctp 文件已呈现在我的 default.ctp
例如,我的 default.ctp 中有我的菜单、页脚等,我的常见问题解答页面在 faq.ctp 我如何推送这些
<?php
echo $this->Html->meta('description','enter any meta description here');
?>
head 标签中的元描述?我需要像 smarty 和 use blocks 这样的模板语言吗?
布局中:
<?php
echo $this->Html->meta('description',$description);
?
在您的 faq.ctp 或 faq() 方法中:
<?php
$this->set('description','enter any meta description here');
?
将此添加到您的 ctp
文件中(没有 echo )
<?php $this->Html->meta('description', 'some text here', ['block' => true]);?>
并将此行添加到您的布局中
<?php echo $this->fetch('meta');?>
另请参阅标题类似的问题:$this->set('title', 'Title Name'); not working in CakePHP 3.x
我正在尝试在 cakephp 3 中使用 meta 标签和描述。到目前为止它工作正常,但我面临的问题是我无法将它放在我的页面中,因为我的 .ctp 文件已呈现在我的 default.ctp
例如,我的 default.ctp 中有我的菜单、页脚等,我的常见问题解答页面在 faq.ctp 我如何推送这些
<?php
echo $this->Html->meta('description','enter any meta description here');
?>
head 标签中的元描述?我需要像 smarty 和 use blocks 这样的模板语言吗?
布局中:
<?php
echo $this->Html->meta('description',$description);
?
在您的 faq.ctp 或 faq() 方法中:
<?php
$this->set('description','enter any meta description here');
?
将此添加到您的 ctp
文件中(没有 echo )
<?php $this->Html->meta('description', 'some text here', ['block' => true]);?>
并将此行添加到您的布局中
<?php echo $this->fetch('meta');?>
另请参阅标题类似的问题:$this->set('title', 'Title Name'); not working in CakePHP 3.x