is this possible? I'm using one controller for (almost) the same functionality for two different pages. Is it possible to distinguish the source of the request in order to vary functionality?
Note: This controller is used to process ajax calls.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityis this possible? I'm using one controller for (almost) the same functionality for two different pages. Is it possible to distinguish the source of the request in order to vary functionality?
Note: This controller is used to process ajax calls.
You can get the current url with Mage::helper('core/url')->getCurrentUrl()
.
As @mbalparda said, the request object could be better for your purposes.
Try these methods:
$request = $this->getRequest();
$request->getRouteName();
$request->getControllerName();
$request->getActionName()
With this you can get your route, controller and action without parsing an URL.
Mage::app()->getRequest()->getServer('HTTP_REFERER')
could be useful.
Use $this->getRequest()
to see how can you differentiate the requests. Inside that var you will have some more details about the request. Dump it and see what is inside and act consequently with the info.