【发布时间】:2013-07-06 06:30:10
【问题描述】:
在 Magento 中,如何在 cms 页面中调用 phtml 文件来设置页面标题,我在 phtml 文件中设置了哪个标题?我正在使用
$this->getLayout()->getBlock('head')->setTitle('your title');
设置页面标题。
【问题讨论】:
在 Magento 中,如何在 cms 页面中调用 phtml 文件来设置页面标题,我在 phtml 文件中设置了哪个标题?我正在使用
$this->getLayout()->getBlock('head')->setTitle('your title');
设置页面标题。
【问题讨论】:
在 cms 页面或 cms 静态块中调用 phtml 文件:
{{block type="core/template" template="templateFolder/your_template.phtml"}}
如果您知道 phtml 文件的块文件(php 文件)所在的位置,那么您可以将其用作类型。
示例: 假设你要调用位于catalog/product 文件夹下的new.phtml 文件,并且你知道它对应的Block 文件(php 文件)位于Catalog/Product 文件夹下,那么你可以使用:
{{block type="catalog/product" template="catalog/product/new.phtml"}}
更多阅读:here
希望这会有所帮助!
【讨论】:
在 cms 块或 cms 页面中使用模板文件时,您无法更改页面的标题,因为在解析页面(或块)内容时已经呈现 head 块。
【讨论】:
正如@Marius 所说,无法从 cms 页面的 phtml 文件中更改页面标题
您需要在 cms 页面中添加它的设计,如下所示:
<reference name="head">
<action method="setCustomTitle" translate="title"> <title> Custom Title </title> </action>
</reference>
【讨论】:
在 CMS > 页面 > 管理内容 > 选择特定的 CMS 页面下添加以下 XML 片段
导航到“设计”选项卡 > 布局更新 XML >
<reference name="head">
<action method="setCustomTitle" translate="title"> <title> Custom Title </title> </action>
</reference>
确保以下 CACHE 文件夹已删除: {根 Magento 文件夹}/var/cache {根 Magento 文件夹}/var/full_page_cache
希望这会有所帮助!
快乐编码...
【讨论】: