简体   繁体   中英

How to Get CMS page title by store in Magento?

I am using magento 1.7.0.2 and I need to display the title of CMS page in my store.
I have two stores, one is in English and the other is in French. To get the title of the CMS page I am using below code

$page = Mage::getModel('cms/page')->load('legal');

Here 'legal' is my page identifier. I have created two pages in my admin panel having the same url key for english and french store having different page titles. But when I try to get the title using,

$pageTitle = $page->getTitle();

It always displays me the title of English CMS page. I have also tried to load the page using,

$page = Mage::getModel('cms/page')->setStore(Mage::app()->getStore()->getId())->load('legal');

without success. Any Idea??

Have a look at Mage_Cms_Helper_Page . It explains how pages are rendered.

Instead of using setStore() , try setStoreId() :

Mage::getModel('cms/page')->setStoreId(Mage::app()->getStore()->getId())->load('legal');

If you are creating two pages for both store then

you must have to careful when you assign page to particular store.

Please check for both pages it must be assign to only one store either a English OR French.

These could be main issue to get your pages every time english if you assign both pages in english store.

Please double check from admin.

Hope you can understand my thoughts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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