Magento控制器动作

好的,非常确切地说,我的任务是使用不涉及布局,块或视图的Magento管理模块。什么都没有显示出来。但是,当我在我的模块的adminhtml控制器中调用一个动作时,Magento一直试图渲染一个布局并使其失败,重定向到仪表板时出现“无法加载源代码:http://www.example.com/index.php / admin / modulename / adminhtml_index / actioname“blah,blah,blah。 现在,我已经查看了FireBug的Net输出以获取熟悉的系统操作,例如清除缓存:http://www.example.com/index.php/admin/cache/flushSystem/key/88848f202df8f254b3db13762ad7e949/这也是响应“无法加载源代码:http://www.example.com/index.php/admin/cache/flushSystem/key/88848f202df8f254b3db13762ad7e949/” 首先,这必须是一个扩展Mage_Adminhtml_Controller_Action的控制器,否则我无法判断管理员是否已登录并且有权操作我的控制器。其次,我没有一个调试系统(而且我的公司在软件工程上花钱也很便宜)所以我不得不让人调试。所以我的问题是,如何在不加载布局和渲染块的情况下调试我的代码并从Magento获取输出?我试图在predispatch方法中输出并在predispatch结束之前退出并且这个工作,但我不想在predispatch中进行任何编码。任何帮助将不胜感激。     
已邀请:
当Firebug说“无法加载源”时,这意味着没有数据可以显示,通常是在302重定向期间。在重定向中,只发送标题而没有正文。这符合您的体验。 其次,您的网址包含
admin/modulename/adminhtml_index/actionname
,其中包含四个部分。在Magento应该只有三个部分,如“路由器/控制器/动作”,哪一部分是你的? 当你有正确的动作射击时不要调用
$this->loadLayout()->renderLayout()
因为那样,嗯,加载布局。输出任何其他内容使用:
$this->getResponse()->setBody($content);
    
如果您只需要添加配置面板,则可以通过system.xml完成​​,ACL通过config.xml或adminhtml.xml进行描述 您的app / etc / modules / Your_Extension.xml将是
<config>
    <modules>
        <Your_Extension>
            <active>true</active>
            <codePool>local</codePool>
        </Your_Extension>
    </modules>
</config>
你的app / code / local /你的/扩展/ etc / config.xml会是
<?xml version="1.0"?>
<config>
    <modules>
        <Your_Extension>
            <version>0.1.0</version>
        </Your_Extension>
    </modules>
    <adminhtml>
        <acl>
            <resources>
                <admin>
                    <children>
                        <system>
                            <children>
                                <config>
                                    <children>
                                        <extension>
                                            <title>Extension section</title>
                                        </extension>
                                    </children>
                                </config>
                            </children>
                        </system>
                    </children>
                </admin>
            </resources>
        </acl>
    </adminhtml>
</config>
和app / code / local /你的/ Extension / etc / system.xml
<?xml version="1.0"?>
<config>
    <sections>
        <extension>
            <label>extension</label>
            <tab>sales</tab>
            <frontend_type>text</frontend_type>
            <sort_order>306</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
            <groups>
                <general translate="label comment">
                    <comment><![CDATA[short description for one field extension]]></comment>
                    <label>General</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>1</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <enable_extension>
                            <label>Activate extension</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>1</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment><![CDATA[Activation flag you can access later from code]]></comment>
                        </enable_extension>
                    </fields>
                </general>
            </groups>
        </extension>
    </sections>
</config>
这就是您需要定义一个新的扩展,在管理端有一个配置字段,只需要三个文件Your_Extension.xml,config.xml和system.xml。 没有控制器需要什么,如果管理员已登录,则无需检查控制器,因为这是由ACL处理的     

要回复问题请先登录注册