4

I have two store views, for 2 languages. I have a page 'foo' defined in both languages (i.e. store views). I'm using

$aCmsPage = Mage::getModel('cms/page')->load('foo', 'identifier');

However, I always get the page in the same language.

Shouldn't I get the page for the current store view?

What am I doing wrong?

Tero Lahtinen
  • 571
  • 2
  • 8
  • 22

3 Answers3

10

You can use below code:

$identifier='foo';
    $page   = Mage::getModel('cms/page');
            $pageId = $page->checkIdentifier($identifier, Mage::app()->getStore()->getId());
            if ($pageId) {
               aCmsPage = Mage::getModel('cms/page')->load($pageId);
            }
Amit Bera
  • 77,456
  • 20
  • 123
  • 237
1

You can use helper class Mage_Cms_Helper_Page's method getPageUrl, it gives the result of cms page URL with the correct store view

Mage::helper('cms/page')->getPageUrl($pageid);
Amit Bera
  • 77,456
  • 20
  • 123
  • 237
1

you have to set store id in call like

$cmsPage = Mage::getModel('cms/page')->setStore(Mage::app()->getStore()->getId())->load('foo', 'identifier');

so it will load cms page per current store.

hope this will sure work for you.

liyakat
  • 3,995
  • 7
  • 27
  • 35