如何在Magento管理员中获取页面/部分的URL [英] How to get the URL of a page/section in Magento admin

查看:64
本文介绍了如何在Magento管理员中获取页面/部分的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎找不到关于这个问题的明确答案.您如何在管理后端中获取页面的网址?

I can't seem to find a definitive answer on this one. How do you get a url to a page in the admin backend?

例如,假设我有一个使用控制器的模块,该控制器的前端名称为 mymodule .如果我打电话:

For example, let's say I have a module that uses a controller with a frontname of mymodule. If I call:

$this->getUrl('mymodule/controller/action')

我得到:

http://mydomain.com/index.php/mymodule/controller/action

这不起作用,因为它不包含管理员的姓氏.

This doesn't work because it doesn't have the admin frontname included.

我发现此线程提到了使用以下方法:

I found this thread that mentions using this:

Mage::helper("adminhtml")->getUrl();

但是,该方法也不会将admin frontname附加到URL上...那么将其通过adminhtml帮助器传递的意义何在?该线程还说,您可以使用它来获取管理员的姓氏:

However that doesn't append the admin frontname to the URL either...so what's the point of passing it through the adminhtml helper? The thread also says you can use this to get the admin frontname:

Mage::getConfig()->getNode('admin/routers/adminhtml/args/frontName');

那么我应该使用这两种方法来构建正确的URL,还是有一种更简单的方法来完成此操作?我认为必须有一种简单的方法,但我只是想不通.

So am I supposed to build the correct URL using these 2 methods or is there an easier way to accomplish this? I would figure there has to be an easy way, but I just can't figure it out.

谢谢:)

推荐答案

我想我已经解决了这个问题,但是如果我弄错了,请发表评论或添加自己的答案.我的第一个问题是config.xml配置不正确.我在<routers>元素下使用的是<frontend>而不是<admin>.我也有<use>standard</use>而不是<use>admin</use>.复制粘贴错误;)

I think I figured this one out, but please comment or add your own answer if I'm mistaken. My first issue was that my config.xml was configured incorrectly. I had <frontend> instead of <admin> under the <routers> element. I also had <use>standard</use> instead of <use>admin</use>. Copy-Paste mistake ;)

但是,这似乎并没有改变返回的URL,但这似乎无关紧要.现在,即使我重定向到的url不包含管理员名字,它也能正确地击中我的控制器.因此,我对此感到有些困惑,但是无论如何,它都是有效的.

However, that still didn't seem to change the URL being returned, but that doesn't seem to matter. It's now correctly hitting my controller, even though the url I'm redirecting to doesn't contain the admin frontname. So I'm a bit confused about that, but regardless, it's working.

这篇关于如何在Magento管理员中获取页面/部分的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆