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

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

问题描述

我似乎无法找到有关此问题的明确答案.你如何在后台获取一个页面的 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.

我发现这个线程提到使用这个:

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

但是,这也不会将管理员前端名称附加到 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');

那么我应该使用这 2 种方法构建正确的 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 配置不正确.我在 元素下使用 而不是 .我还有 standard 而不是 admin.复制粘贴错误;)

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 admin 中获取页面/部分的 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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