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

时间:2013-07-06 06:30:11

标签: php magento

在Magento中如何调用cms页面中的phtml文件来设置我在我的phtml文件中设置的标题?我正在使用

$this->getLayout()->getBlock('head')->setTitle('your title'); 

设置页面标题。

4 个答案:

答案 0 :(得分:9)

要在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

希望这有帮助!

答案 1 :(得分:2)

在cms块或cms页面中使用时,无法从模板文件更改页面标题,因为在解析页面(或块)内容时已呈现head块。

答案 2 :(得分:0)

如@Marius已经告知的那样,无法从cms页面的phtml文件中更改页面标题

你需要在cms页面中添加它的设计,如下所示:

<reference name="head">
   <action method="setCustomTitle" translate="title"> <title> Custom Title </title> </action>
</reference>

答案 3 :(得分:0)

在CMS&gt;下添加以下XML片段页面&gt;管理内容&gt;选择特定的CMS页面

导航至“设计”标签&gt;布局更新XML&gt;

 <reference name="head">
     <action method="setCustomTitle" translate="title"> <title> Custom Title  </title> </action>
 </reference>

确保下面的CACHE文件夹已删除: {Root Magento Folder} / var / cache {Root Magento Folder} / var / full_page_cache

希望这有帮助!

快乐编码......

相关问题