scope can be one of those things... if you change it from the root level with a <% control Something %> you need to use something like $Top.ifReferrerSwitchImage or <% control Top %>$ifReferrerSwitchImage<% end_control %>
Thanks for your reply! Not quite understanding though sorry.
Perhaps I didn't explain it well enough. The method that I can't access is getHeader. Using the example above I get the error: "Call to a member function getHeader() on a non-object".
I guess it's my lack of knowledge, I just don't know where I am in the overall scope of silverstripe or how to travese the different levels of objects to get the getHeader method. Don't suppose you know where I can learn more about that?
"Call to a member function getHeader() on a non-object". means that "$this->owner->request" is a non object.
Since I don't fully understand what is going on with that I'd advise setting debug mode and doing some "Debug::show($this)" and such around it. also if it is a non-object sometimes and others it is an object, test it first... e.g.
if ($this->owner->request) return $this->owner->request->getHeader('Referer');
Surely deugging is straightforward (http://doc.silverstripe.org/sapphire/en/topics/debugging)?
I trusted that the bit you had "worked out" worked and you knew what you were doing and your issues was first in the template and then some other reason... maybe if you hand;t included code that obviously does not work - or indicated that it didn't work that might have helped.
why don't you just return $_SERVER['http_referer'] itself?
Sorry, I didn't mean to suggest that you weren't helping. I was just frustrated because I wasn't getting anywhere. I appreciate that your trying your best to help :)
When I use $_SERVER I get un-defined index, I wanted to reference it properly through the framework.
I can see now when I re-read my original message that I'm suggesting that the problems in the template. I sohuld of been more clear.
The code I provided doesn't work, I get non-object when trying to call getHeader and I'm not sure what object it belongs to or how get at it from within my function so that I can return it to the template.