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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Simple Page_Controler Function giving 404?


Go to End


2 Posts   854 Views

Avatar
otherjohn

Community Member, 125 Posts

11 June 2010 at 7:46am

Hi all

in my /mysite/code/page.php
i have

 class Page_Controller extends ContentController { 

public function  MobileOff(){
    	$_SESSION['mobilePhone']="None";
   		Director::redirect(Director::baseURL().$this->URLSegment);
	}

but when I navigate to site.com/MobileOff it gives me a page cannot be found.
What am I missing?
John

Avatar
Willr

Forum Moderator, 5523 Posts

11 June 2010 at 7:28pm

Well because out of the box the URL rules will match that to a Page. To do that you would have to use the url

site.com/home/MobileOff

And make sure its an allowed action. http://doc.silverstripe.org/security#security_in_controllers