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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

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

Controller URL

Go to End

3 Posts   997 Views


Community Member, 7 Posts

22 February 2014 at 12:04pm


I am following the advice given in this thread:

"You can execute a controller function using the the $Page/$Action/$Parameter url pattern, where $Page is the URL, the $Action is the name of the controller function and $Parameter is an variable you may need to push."

Therefore I am attempting to call a controller function as follows:

In my Page.php I have the following:

class Page extends SiteTree {

	private static $db = array(

	private static $has_one = array(
	public static $allowed_actions = array (
	public function test(){
		echo "hello world!";


class Page_Controller extends ContentController {

	private static $allowed_actions = array (

	public function init() {



This is a fresh install of version 3.12, it couldn't be any more rudimentary - the output I get is "Page cannot be found".

Any suggestions?




Forum Moderator, 5523 Posts

22 February 2014 at 2:06pm

Couple points:

Does the page exist in the CMS? Say you have a home page created in the CMS with the URL 'Home' the route would be /home/action. If you don't want to have to create the page in the CMS then you have to define the full route in routes.yml

Your test function needs to be in the controller, not the model.

You need to make sure 'test' is listed as an allowed action on the controller. explains some of the concepts for general controllers. Page_Controllers have the slight difference in that a Page must exist in the CMS for them to work.


Community Member, 7 Posts

22 February 2014 at 11:48pm

That fixed it, it wasn't in the allowed actions, adding it gives me the expected output.

Many thanks!