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

前端 未结 3 886
眼角桃花
眼角桃花 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:52

    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 ({{...}})

提交回复
热议问题