Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

$this->request->getVar() error in controller


Go to End


2 Posts   5485 Views

Avatar
nekranox

Community Member, 31 Posts

19 November 2010 at 12:56am

Hey guys,

This looks like something really simple but I just can't figure it out.

Front-end loads fine, dev/build works fine but when I try to go to admin I get:

Fatal error: Call to a member function getVar() on a non-object in /mysite/code/Page.php on line 23

Here's the offending function in Page.php:

	function BigFont() {
		$BigFont = $this->request->getVar('bigfont');
		if($BigFont == 'true') {
			return true;
		} else {
			return false;
		}
	}

So it looks like I'm not accessing getVar properly. Strangely, it works on the front end of the site!

Any ideas?

Avatar
rob.s

Community Member, 78 Posts

22 November 2010 at 8:59pm

Edited: 22/11/2010 9:02pm

Hi,

are you using ->getVar() in your Page class or Page_Controller class?

If it's in Page class, try

Controller::curr()->getRequest()->getVar()

If in Page_Controller, try

$this->getRequest()->getVar()

Greetings,
Rob