How to call phtml file on cms page to set page title

In Magento, how do I call the phtml file on the cms page to set the title of the page whose name I set in my phtml file? I use

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

to set the page title.

+4
source share
4 answers

To call the phtml file on the cms or cms static block page:

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

If you know where the block file (php file) for your phtml file is located, you can use it as a type.

Example: Suppose you want to call the new.phtml file, which is located in the catalog / Product folder, and you know that its corresponding lock file (php file) is located in the Catalog / Product folder, then you can use:

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

Additional information: here

Hope this helps!

+9
source

You cannot change the page title from the template file when using it on the cms or cms page, because the head block is already displayed when analyzing the contents of the page (or block).

+2
source

Unable to change page name from phtml cms page file as @Marius said

you need to add a project to it on the cms page, as shown below:

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

Add the following XML part to CMS> Pages> Content Management> Select a specific CMS page

Go to Design tab> XML Update Layout>

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

Make sure the CACHE folders are selected below: {Magento root folder} / var / cache {Magento root folder} / var / full_page_cache

Hope this helps!

Happy coding ...

0
source

Source: https://habr.com/ru/post/1490013/


All Articles