-2

There is core magento modules Cms with class Page, which prepare and render available pages for Store View. How to call in my controller necessary method and pass to my template or render on my page?

3
  • cms means cms model ya other ..need explanation
    – Amit Bera
    Commented Apr 17, 2015 at 6:50
  • @AmitBera I am not really good in magento now, so maybe can say another words. I need render on my page all available pages for website, store and store view. Something like on magento Admin Panel CMS - Pages.
    – Maxim R
    Commented Apr 17, 2015 at 6:59
  • got your point.Please try rajeev answer and let me know ,if you have any help
    – Amit Bera
    Commented Apr 17, 2015 at 7:00

1 Answer 1

3

If you want to customize the default behaviour of PageController.php present in Mage_Cms module, then you need to rewrite this controller. For more details on how to rewrite a controller, you can refer this link

In short, this is what you need to do in order to rewrite Mage_Cms controllers.

File : app\code\local\Namespace\Module\etc\config.xml

<config>
    <frontend>
        <routers>
            <cms>
                <args>
                    <modules>
                        <namespace_module before="Mage_Cms">Namespace_Module</namespace_module>
                    </modules>
                </args>
            </cms>
        </routers>
    </frontend>
</config>

and then

File : app\code\local\Namespace\Module\controllers\PageController.php

<?php
require_once(Mage::getModuleDir('controllers','Mage_Cms').DS.'PageController.php');

class Namespace_Module_TagController extends Mage_Cms_PageController
{
    // some code
}

Now you can modify the required methods inside this controller. Since you are rewriting Mage_Cms_PageController using your custom controller, Magento will use your custome controller instead of Mage_Cms_PageController.

Now what if you don't want customize CMS Page controller, but you want to use the feature of that section in your custom module, then you need to define your controller in normal way in your config.xml and then just extend the Mage_Cms_PageController. ie your controller will look like this.

<?php
require_once(Mage::getModuleDir('controllers','Mage_Cms').DS.'PageController.php');

class Namespace_Module_TagController extends Mage_Cms_PageController
{
    // some code
}

The major difference here is, you are not rewriting the Mage_Cms module via config.xml. Since you are extending Mage_Cms_PageController in this way, your controller will get all of the power of that controller. Now do your customization here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.