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:

Data Model Questions /

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

[SOLVED ]Routing example for YAML Config / DataObject needed

Go to End

3 Posts   1361 Views

Optic Blaze

Community Member, 190 Posts

5 October 2013 at 9:49am

Hi there,

I've been reading through the docs regarding routing and i am a bit confused.
I currently have the following:


class Customer_Controller extends Controller {

public static $allowed_actions = array ();

public function init() {
return $this->renderWith('Customer');

//Set up URL handler
private static $url_handlers = array(


# i want to be able to render the template if the user types the following url..... mysite/customer/
# i am trying to avoid hooking onto the Page Class because there will be alot of data and i dont want to involve SiteTree
# as far as i can see from the docs i am supposed to be able to do this either via the YAML config file or $url_handlers

I am not sure how to configure the YAML file to do this.



Forum Moderator, 5523 Posts

6 October 2013 at 5:42pm

Edited: 06/10/2013 5:42pm

In your routes.yml you need to define the rule you current have as a url_handler. The configuration defined in url_handler is used *once* the controller has matched.

Name: myroutes
After: framework/routes#coreroutes
'customer//$Action/$ID/$Name': 'Customer_Controller'

(Note forum strips whitespace, you'll need to 2 space each for lines)

You can remove the url_handler for your class (as it's not doing anything special in your instance)

Optic Blaze

Community Member, 190 Posts

8 October 2013 at 11:51am

Thanks...this worked well