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

Silverstripe Routing


Go to End


2 Posts   695 Views

Avatar
Newbie

Community Member, 4 Posts

3 March 2016 at 5:41am

Edited: 03/03/2016 5:52am

I'm following the documentation with the code, but http://localhost/silverstripe/teams or http://localhost/silverstripe/player does not work?

TeamController.php
<?php

class TeamController extends Controller {

private static $allowed_actions = array(
'players',
'index'
);

public function index(SS_HTTPRequest $request) {
// ..
}

public function players(SS_HTTPRequest $request) {
print_r($request->allParams());
}
}

config.yml
---
Name: mysite
After:
- 'framework/*'
- 'cms/*'
---
# YAML configuration for SilverStripe
# See http://doc.silverstripe.org/framework/en/topics/configuration
# Caution: Indentation through two spaces, not tabs
SSViewer:
theme: 'simple'

Director:
rules:
'teams//$Action/$ID/$Name': 'TeamController'
'player/': 'PlayerController'
'': 'HomeController'

Avatar
martimiz

Forum Moderator, 1391 Posts

11 March 2016 at 9:59am

At a first glance I see that while the action is 'players' (plural), you created a routing for 'player' (singular)...