【问题标题】:magento:generate cms pages dynamicallymagento:动态生成 cms 页面
【发布时间】:2011-10-14 00:47:43
【问题描述】:

大家好,

我需要知道 CMS 页面是否可以动态创建,对应于 Magento 中创建的每个新产品。或者简单地在 magento 中动态创建 CMS 页面。

我对此进行了大量研究,但找不到任何确切的内容。 (我使用的是 Magento 1.5。)

请帮助是否可能?如果不是,为什么?我至少需要知道为什么不能在 Magento 中动态创建 CMS 页面。

任何帮助将不胜感激。 非常感谢

【问题讨论】:

    标签: magento content-management-system


    【解决方案1】:

    这是动态/编程创建CMS页面的代码:-

    Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
    
    $cmsPage = array(
                'title' => 'My CMS Page',
                'identifier' => 'cms-page',
                'content' => 'Sample CMS Page',             
                'is_active' => 1,
                'sort_order' => 0,
                'stores' => array(0),
                'root_template' => 'three_columns'
                );
    
    Mage::getModel('cms/page')->setData($cmsPage)->save();
    

    请注意Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);这行只有在您从前端创建 CMS 页面时才需要

    【讨论】:

    • 不客气!如果它有效,那么不要忘记接受并投票给答案;)
    猜你喜欢
    • 2011-08-30
    • 2012-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-14
    • 2019-12-13
    • 1970-01-01
    相关资源
    最近更新 更多