I'm trying add a simple template to CMS page using a block type from a local module. This template will rely on http_referer and request params.
In the Design > Layout Update XML part of the CMS page
, I added
<reference name="content">
<block type="gbicm/modal" name="gbicmmodal" template="gbicm/modal.phtml" />
</reference>
To start, the template calls $this->method()
which simply returns $_SERVER["HTTP_REFERER"]
for testing, but it is returning null
in all cases. I've created a link to this page from another cms page, and when I click the link it returns null
. I haven't tried using a controller class to get it, because I can't find any examples that do this from a block class.
Am I going about this incorrectly? Does $_SERVER["HTTP_REFERER"]
not function in a block class? Can I access a controller/router class/singleton to get request information?
Update: Mage::helper('core/http')->getHttpReferer()
gives me empty string when I land on the cms page from a link in another page.
Best Answer
Try using
Mage::helper('core/http')->getHttpReferer()
Anyway, first try to return a string from your method since I think the issue you are experiencing is there and not in the$_SERVER["HTTP_REFERER"]
part.