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.
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.