How would I pull the content of a CMS page into a static block?

前端 未结 3 770
眼角桃花
眼角桃花 2021-02-04 19:25

I want to pull the content of a CMS page into my static block, if you know of a way to do this I would be grateful.

3条回答
  •  野的像风
    2021-02-04 19:50

    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

提交回复
热议问题