magento显示请求url

发布于 2024-12-17 16:01:06 字数 349 浏览 0 评论 0原文

我想显示模块,控制器,被调用的方法

我认为cms模块在

应用\代码\核心\Mage\cms\

调用 IndexController.php 并使用 IndexAction 方法。因为它是默认页面 url。

但是当我尝试在 IndexAction 方法中回显某些内容时,什么也没有出现。我什至尝试手动调用它,它仍然重定向到主页。

本地主机/magento/index.php/cms/index/index/

我做对了吗? 我怎样才能显示在magento中调用的请求url?

i wanted to display the module,controller,method being called

i thought that the cms module found in the

app\code\core\Mage\cms\

calls the IndexController.php and uses the IndexAction method .since it is the default page url.

but when I tried to echo out something inside the IndexAction method .nothing comes out. I even tried to call it manually and it still redirects to the home page.

localhost/magento/index.php/cms/index/index/

am i doing it right?
how can i display the request url being called in magento?

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

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

发布评论

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

评论(5

长不大的小祸害 2024-12-24 16:01:06

我也在找这个,具体方法如下:

echo Mage::helper('core/url')->getCurrentUrl();

I was looking for this also, here's how to do it:

echo Mage::helper('core/url')->getCurrentUrl();
暮倦 2024-12-24 16:01:06

您好,您可以尝试输出以下内容

<?php
    echo Mage::app()->getRequest()->getModuleName();
    echo Mage::app()->getRequest()->getControllerName();
    echo Mage::app()->getRequest()->getActionName();
?>

未经测试,但也许您可以执行类似的操作

<?php
    echo Mage::app()->getRequest()->getRequestUri();
?>

希望这有

帮助

Hi you could try to output the following

<?php
    echo Mage::app()->getRequest()->getModuleName();
    echo Mage::app()->getRequest()->getControllerName();
    echo Mage::app()->getRequest()->getActionName();
?>

Not tested but maybe you can do something like this

<?php
    echo Mage::app()->getRequest()->getRequestUri();
?>

Hope this helps

greetings

北陌 2024-12-24 16:01:06

我需要 URL 段,所以我使用了这个:

function getUrlSegment($i) {
    $_baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
    $_currentUrl = Mage::helper('core/url')->getCurrentUrl();
    $_path = str_replace($_baseUrl, '', $_currentUrl);
    $_segments = explode('/', rtrim($_path, '/'));
    return $_segments[$i];
}

// Would get 'store' if URL: http://example.com/store/product/123
$root = getUrlSegment(1); 

I needed the URL segments, so I used this:

function getUrlSegment($i) {
    $_baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
    $_currentUrl = Mage::helper('core/url')->getCurrentUrl();
    $_path = str_replace($_baseUrl, '', $_currentUrl);
    $_segments = explode('/', rtrim($_path, '/'));
    return $_segments[$i];
}

// Would get 'store' if URL: http://example.com/store/product/123
$root = getUrlSegment(1); 
醉生梦死 2024-12-24 16:01:06

您可能会使用控制器中的回显在日志文件中收到“标头已发送”警告。不要使用 echo,而是使用 Mage::log,例如

Mage::log('My request url is: '.$requestUrl);

日志行应出现在 /var/logs/system.log 文件中。

You might be getting 'headers already sent' warnings in your log files using an echo in the controller. Instead of using echo use Mage::log, e.g.

Mage::log('My request url is: '.$requestUrl);

The log line should appear in the /var/logs/system.log file.

多情出卖 2024-12-24 16:01:06

路由 cms/index/index 仅用于主页。其他标准页面(例如“no-route”和“enable-cookies”)可以选择通过 IndexController 上的特定操作进行处理。其余页面由 Mage_Cms_PageController::viewAction() 处理。尝试路径 cms/page/view/id/customer-service< /a> 看看。该参数是id,因此下一个术语customer-service是您在管理中设置为“URL Key”的页面标识符。

The route cms/index/index is only ever used for the home page. Other standard pages like "no-route" and "enable-cookies" are optionally handled by specific actions on the IndexController. The remaining pages are handled by Mage_Cms_PageController::viewAction() instead. Try the path cms/page/view/id/customer-service to see. The parameter is id and so the next term customer-service is the page identifier which you set in the admin as "URL Key".

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