Facebook fans

Latest from Twitter

Magento use CMS page in another page

Posted date: 31 Aug 2011 | Posted by: admin | 0 comments

Sometimes, you want to use information like title or content from a CMS page (or multiple CMS pages) in another page. For example, you want to show a part of “Welcome” page in homepage. How can you do the task?

Today I will show you that how you can use CMS pages in another page.

  • To use information of a CMS page in another page, you will need the identifier (URL key) of this CMS page. Then in the page you want to use the information, put some codes as following:
  • $aCmsPage = Mage::getModel('cms/page')->load('URL-key-of-this-page', 'identifier');
    $theTitle = $aCmsPage->getTitle();
    $theContent = $aCmsPage->getContent();
    
    Then you can use this title and content anywhere you want!
  • To get information from multiple CMS pages, we need to use CMS page collection:
  • $collection = Mage::getModel('cms/page')->getCollection()->addStoreFilter(Mage::app()->getStore()->getId());
    $collection->getSelect()->where('is_active = 1'); // use the filter in the case you want to get only enabled CMS pages.
    foreach ($collection as $page) {
        $theIdentifier = $page->getIdentifier();
        $theTitle = $page->getTitle();
        $theContent = $page->getContent();
        ....// use these like you want!
    }

Thats it ! Let try and enjoy!

If you have any problem or any query in this or if you want any help from myside, just comment on this.

Thanks !

It's useful? Like this article!

Comments are closed.

Share this

Related posts

Pinterest Fan Box – Add Pinterest Followers to your Magento site image

Pinterest Fan Box, do you know how to add your Pinterest...

7 Apr 2012
Pinterest Feeds – Add Pinterest Pin Board to Magento Site image

Pinterest Feeds to Magento sites, how to do the...

23 Mar 2012
Pinterest Magento Linker image

Pinterest is one of the hottest social networks and is...

14 Mar 2012
Debugging magento templates image

Developing in Magento without these debugging tips can be...

14 Oct 2011

Mirage Design @ 2011 | Web development, Website design, Magento development, Wordpress development

Pinterest Tutorial   Ty so bong da   Tim chung cu