Magento display request url

I wanted to display a module, controller, method called

I thought the cms module found in

Application \ Code \ Kernel \ Mage \ K \

calls IndexController.php and uses the IndexAction method. Because it is the default URL of the page.

but when I tried to snatch something inside the IndexAction method. nothing comes out. I even tried calling it manually, and it is still redirecting to the home page.

local / Magento / index.php / CMS / index / index /

Am I doing it right? How can I display the request url in magento?

+5
source share
5 answers

, :

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

,

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

, , , -

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

,

+9

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); 
+2

" " . Mage:: log, .

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

/var/logs/system.log.

0

cms/index/index . , "no-route" "enable-cook", IndexController. Mage_Cms_PageController::viewAction(). cms/page/view/id/customer-service. id, customer-service , admin "URL-".

0
source

All Articles