带有块cms_index_index的Magento布局cms.xml文件不显示cms页面内容。为什么?

时间:2012-04-20 15:51:35

标签: php magento layout

我创建了一个Magento Frontend Package&主题...我已经创建了一个包含以下内容的layout / cms.xml文件。在主页上,现在有页面标题但没有内容?

<layout version="0.1.0">
    <default>
        <reference name="footer">
            <block type="cms/block" name="cms_footer_links" before="footer_links">
                <action method="setBlockId"><block_id>footer_links</block_id></action>
            </block>
        </reference>
    </default>

    <cms_page translate="label">
        <label>CMS Pages (All)</label>
        <reference name="content">
            <block type="core/template" name="page_content_heading" template="cms/content_heading.phtml"/>
            <block type="page/html_wrapper" name="cms.wrapper" translate="label">
                <label>CMS Content Wrapper</label>
                <block type="cms/page" name="cms_page"/>
            </block>
        </reference>
    </cms_page>

    <cms_index_index translate="label">
        <label>CMS Home Page</label>
        <reference name="content">
            <block type="core/template" name="cms_index_index" template="cms/index/index.phtml" />
            <block type="cms/page" name="cms_page" />

            <block type="page/html_wrapper" name="cms.wrapper" translate="label">
                <label>CMS Content Wrapper</label>
                <block type="cms/page" name="cms_page"/>
            </block>
        </reference>
    </cms_index_index>

    <cms_index_defaultindex>
        <remove name="right"/>
        <remove name="left"/>

        <reference name="content">
            <block type="core/template" name="default_home_page" template="cms/default/home.phtml"/>
        </reference>
    </cms_index_defaultindex>

    <cms_index_noroute translate="label">
        <label>CMS No-Route Page</label>
    </cms_index_noroute>

    <cms_index_defaultnoroute>
        <remove name="right"/>
        <remove name="left"/>

        <reference name="content">
            <block type="core/template" name="default_no_route" template="cms/default/no-route.phtml"/>
        </reference>
    </cms_index_defaultnoroute>
</layout>

正如您所看到的,其中有<block type="cms/page" name="cms_page" />,但前端没有任何内容。为什么?任何提示?

谢谢!

1 个答案:

答案 0 :(得分:1)

// get current cms page from Mage:getSingleton
$cms_id = Mage::getSingleton('cms/page')->getIdentifier();
$cms_title = Mage::getSingleton('cms/page')->getTitle();
$cms_content = Mage::getSingleton('cms/page')->getContent();

感谢http://developerafroz.blogspot.de/2012/01/get-current-cms-page-magentocms-pages.html