如何在cms页面中调用phtml文件来设置页面标题


How to call a phtml file in cms page to set page title

在Magento中,如何在cms页面中调用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"}}

更多阅读:点击这里

希望这能有所帮助!

在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

希望这能有所帮助!

快乐编码。。。