Magento 自定义管理菜单下拉菜单

发布于 2024-11-19 05:13:36 字数 1289 浏览 4 评论 0原文

我需要一点帮助:我正在开发一个管理模块,在其中创建两个菜单。我想在 config.xml 中设置链接,但我不明白。我的config.xml如下。

<children>
    <menuitem1 module="PrecosMargens">
        <title>Actualizar Preços Custos</title>
        <action>PrecosMargens/example</action>
    </menuitem1>
    <menuitem2 module="PrecosMargens">
        <title>Actualizar Preços vendas</title>
        <action>PrecosMargens/example2</action>
    </menuitem2>
</children> 

但是使用 MenuItem2 时出现错误 404。你能帮我解决这个问题吗?在控制器文件中,我的内容如下:

class lbonus_PrecosMargens_ExampleController extends Mage_Adminhtml_Controller_Action
{

    public function indexAction()
    {
        // "Fetch" display
        $this->loadLayout();

        // "Inject" into display
        // THe below example will not actualy show anything since the core/template is empty
        $this->_addContent($this->getLayout()->createBlock('core/template')

        //defino o template
        ->setTemplate('PrecosMargens/list.phtml')); 

        // "Output" display
        $this->renderLayout();

    }    
} 

我想做的是有两种不同的布局,一种布局为另一种布局为 link1 和 link2

I need a little help: I’m developing an admin module, where I create two menus. I want to set the links in the config.xml, but I do not get it. My config.xml is as follows.

<children>
    <menuitem1 module="PrecosMargens">
        <title>Actualizar Preços Custos</title>
        <action>PrecosMargens/example</action>
    </menuitem1>
    <menuitem2 module="PrecosMargens">
        <title>Actualizar Preços vendas</title>
        <action>PrecosMargens/example2</action>
    </menuitem2>
</children> 

But with the MenuItem2 get error 404. Can you help me how to solve this? In the controller file I have just as follows:

class lbonus_PrecosMargens_ExampleController extends Mage_Adminhtml_Controller_Action
{

    public function indexAction()
    {
        // "Fetch" display
        $this->loadLayout();

        // "Inject" into display
        // THe below example will not actualy show anything since the core/template is empty
        $this->_addContent($this->getLayout()->createBlock('core/template')

        //defino o template
        ->setTemplate('PrecosMargens/list.phtml')); 

        // "Output" display
        $this->renderLayout();

    }    
} 

I wanted to do is to have two different layouts, one layout to another to link1 and link2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

徒留西风 2024-11-26 05:13:36

第二个操作 (PrecosMargens/example2) 尝试在单独的类 lbonus_PrecosMargens_Example2Controller 中查找方法 indexAction()。您需要两个控制器来执行这两个操作。

您可以使用一个控制器来代替。将操作更改为 PrecosMargens/example/custosPrecosMargens/example/vendas,这会导致匹配方法 custosAction()vendasAction( ) 来使用。

附录

操作(成为 URL 的一部分)采用“路由器/控制器/操作”的形式。路由器通过该模块的 config.xml 文件的 部分与您的模块匹配。
控制器成为类名,并附加“Controller”,因此在这种情况下,“example”成为模块的“ExampleController”。
操作部分通向该类的方法,并附加“操作”。您可以看到“custos”成为 custosAction() 方法。
当这些部分之一丢失时,它默认为“index”,因此默认控制器是“IndexController”,默认操作是“indexAction”。如果您刚刚使用“PrecosMargens”,它将被用作“PrecosMargens/index/index”。

The second action (PrecosMargens/example2) is trying to find a method indexAction() in a separate class lbonus_PrecosMargens_Example2Controller. You need two controllers for the two actions.

You could have one controller instead. Change the actions to PrecosMargens/example/custos and PrecosMargens/example/vendas which cause the matching methods custosAction() and vendasAction() to be used.

Addendum

The action (which becomes part of the URL) is in the form "router/controller/action". The router is matched to your module by the <routers> section of that module's config.xml file.
The controller becomes the class name with "Controller" appended to it, so in this case the "example" becomes your module's "ExampleController".
The action part leads to that class' method with "Action" appended to it. You can see "custos" becomes the custosAction() method.
When one of these parts is missing it defaults to "index", so a default controller is "IndexController" and a default action is "indexAction". If you just used "PrecosMargens" it would be used as if it were "PrecosMargens/index/index".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文