简体   繁体   English

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

[英]How to call a phtml file in cms page to set page title

In Magento how to call a phtml file in cms page to set page title which title I set in my phtml file? 在Magento中,如何在cms页面中调用phtml文件来设置页面标题,即我在phtml文件中设置的标题? I am using 我在用

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

to set page title. 设置页面标题。

To call a phtml file in a cms page or cms static block: 要在cms页面或cms静态块中调用phtml文件,请执行以下操作:

{{block type="core/template" template="templateFolder/your_template.phtml"}}

If you know, where the block file(php file) for your phtml file resides, then you can use it as type. 如果您知道phtml文件的阻止文件(php文件)所在的位置,则可以将其用作类型。

Example: Suppose you want to call new.phtml file that resides in catalog/product folder, and you know that its corresponding Block file(php file) resides in Catalog/Product folder, then you can use: 示例:假设您要调用位于catalog / product文件夹中的new.phtml文件,并且知道其对应的Block文件(php文件)位于Catalog / Product文件夹中,则可以使用:

{{block type="catalog/product" template="catalog/product/new.phtml"}}

More reading: here 更多阅读: 这里

Hope this helps! 希望这可以帮助!

你不能在一个CMS块或CMS页面上,使用它时,因为页面的标题从模板文件更改head时的页面(或块)的内容进行解析块已经呈现。

It's not possible to change page title from phtml file of cms pages as already told by @Marius 就像@Marius所说的那样,无法从cms页面的phtml文件中更改页面标题

you need to add to it's design in cms page as given below : 您需要在cms页面中添加其设计,如下所示:

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

Add the below XML piece under CMS > Pages > Manage Content > Select a specific CMS Page 在CMS>页面>管理内容>选择特定的CMS页面下添加以下XML片段

Navigate to "Design" tab > Layout Update XML > 导航到“设计”选项卡>布局更新XML>

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

Make sure the CACHE folders are DELETED under below: {Root Magento Folder}/var/cache {Root Magento Folder}/var/full_page_cache 确保CACHE文件夹位于以下位置:{Root Magento Folder} / var / cache {Root Magento Folder} / var / full_page_cache

Hope this helps! 希望这可以帮助!

Happy Coding... 快乐编码...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM