1

I have a file mytemp.phtml that I make a post request in and I would like this controller to retrieve it, then pass it back to mytemp.phtml. My controller is not being read by Magento though and I can't find my error. Also, once I get it to be read how do I pass that post retrieval to mytemp.phtml, thanks

config.xml:

<config>
    <-- other -->
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <mymodule before="Mage_Adminhtml">MyApp_MyModule_Adminhtml</mymodule>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
    <!--other-->
</config>

MyApp\MyModule\controllers\Adminhtml\ButtonController.php:

class MyApp_MyModule_Adminhtml_ButtonController extends Mage_Adminhtml_Controller_Action {
    public function indexAction()
    {
        $this->loadLayout();
        $this->renderLayout();
    }
}
1

Create a admin layout.xml in app/design/adminhtml/default/default/layout/myapp_mymodule.xml (update your config.xml as needed see Add template to custom adminhtml button)

<layout>
    <mymodule_adminhtml_button_index>
        <reference name="content">
            <block type="mymodule/button" name="mymodule" template="mymodule/button.phtml" />
        </reference>
    </mycompany_adminhtml_mymodule_index>
</layout>

In your controller save the post variable using register

class MyApp_MyModule_Adminhtml_ButtonController extends Mage_Adminhtml_Controller_Action {
    public function indexAction()
    {
        $this->loadLayout();
        //normally you would post to a new action
        if($this->getRequest()->getPost('param')){
           Mage::register('mymodule_data', $this->getRequest()->getPost('param'));  // or $this->getRequest()->getPost();
         }

        $this->renderLayout();
    }
}

Then in your block (mymodule/button) check to see if Mage::registry('mymodule_data'); exist and display it in your phtml file accordingly

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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