获取Magento中的当前模块和页面标识符?

San*_*raj 8 magento

我需要在Magento中获取当前页面标识符和当前模块.

我使用下面的代码.

Mage::app()->getRequest()->getModuleName() - To get current module.
Mage::getSingleton('cms/page')->getIdentifier() - To get current page
Run Code Online (Sandbox Code Playgroud)

它工作一次清除magento缓存,否则它显示旧页面和模块.

例:

当我们检查主页时,它将"cms"作为模块,将"home"作为页面.现在我点击联系页面,它也显示相同的结果.

清除缓存并检查联系页面后,它将"cms"显示为模块,将"contact"显示为页面标识符.

如何获取当前页面标识符和模块每次没有清除缓存?

San*_*raj 12

要获得当前模块:

Mage::app()->getFrontController()->getRequest()->getModuleName()
Run Code Online (Sandbox Code Playgroud)

要获取当前的CMS页面:

Mage::getSingleton('cms/page')->getIdentifier()
Run Code Online (Sandbox Code Playgroud)