4 thoughts on “How would I pull the content of a CMS page into a static block?”

  1. Haven’t tested this, but it should work. If you have the unique ID of the cms page (not the identifier):

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

    Otherwise if you have the page’s identifier (i.e. URL key), use something like this:

    $urlKey = "url_key";
    $page->load($urlKey,'identifier');
    

    Then finish with:

    $helper = Mage::helper('cms');
    $processor = $helper->getPageTemplateProcessor();
    $html = $processor->filter($page->getContent());
    return $html;
    

    == EDIT ==

    Added the template parsing steps as suggested by Alan

  2. There’s no way (that I know of) to do this out of the box.

    However, as the static block editing interface allows you to insert widgets into static blocks, I’d implement a widget that renders out the contents of a CMS page. I have a basic implementation I’ve been playing with, but have been too busy to flesh out. It’s functional, but wouldn’t be super performance if you tried to insert a large number of widgets during any one http request. Feel free to give it a try; any feedback is appreciated.

    If you’re interested in how to ro programmatically render out a CMS page, checkout the Mage_Cms_Block_Page::_toHtml() method.

        $helper = Mage::helper('cms');
        $processor = $helper->getPageTemplateProcessor();
        $html = $processor->filter($this->getPage()->getContent());
        $html = $this->getMessagesBlock()->getGroupedHtml() . $html;
        return $html;
    

    The call to $this->getPage() returns a cms/page model. The extra code above is necessary,as it passes the page through the filters that replace the directive tags ({{...}})

  3.        $model =Mage::getModel('cms/page')->load('welcome','identifier');
           echo '<h2>'.$model->getContentHeading().'<h2>';
           echo $model->getContent();
    

    Magento CMS Page conten Display code Khaled saifullah

Leave a Reply

Your email address will not be published. Required fields are marked *