Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
magento显示请求url_Url_Magento_Content Management System_Controller_Request - Fatal编程技术网

magento显示请求url

magento显示请求url,url,magento,content-management-system,controller,request,Url,Magento,Content Management System,Controller,Request,我想显示被调用的模块、控制器和方法 我认为cms模块在 app\code\core\Mage\cms\ 调用IndexController.php并使用IndexAction方法。因为它是默认页面url 但当我试图呼应出索引方法中的某些内容时,什么也没有出来。我甚至尝试手动调用它,但它仍然重定向到主页 localhost/magento/index.php/cms/index/index/ 我做得对吗? 如何显示在magento中调用的请求url 使用控制器中的回音,您可能会在日志文件中收到“h

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

我认为cms模块在

app\code\core\Mage\cms\

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

但当我试图呼应出索引方法中的某些内容时,什么也没有出来。我甚至尝试手动调用它,但它仍然重定向到主页

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

我做得对吗?
如何显示在magento中调用的请求url

使用控制器中的回音,您可能会在日志文件中收到“headers ready sent”警告。使用Mage::log代替echo,例如

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

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

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

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

没有测试,但也许你可以这样做

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

希望这有帮助


问候语路线
cms/index/index
仅用于主页。其他标准页面,如“无路由”和“启用Cookie”,可以通过IndexController上的特定操作进行选择性处理。其余页面由
Mage\u Cms\u PageController::viewAction()
处理。试试这条路看看。参数是
id
,因此下一个术语
客户服务
是您在管理中设置为“URL键”的页面标识符。

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

我需要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); 

我应该把它放在哪里?我试着把它放在头上。phtml。我不知道该放在哪个控制器上。indexAction的“i”应该是小写的up所有的都是小写的。indexController和indexAction。嗯,indexController应该是大写:)->名称空间\模块\ indexController扩展。。。和IndexController.phpecho Mage::app()->getRequest()->getRequestUri();-是合法的,谢谢这对于获取完整的请求URL非常有用。