Reputation:
I created some controllers and routes in SilverStripe but I am unable to access the routes.
http://localhost/silverstripe/teams or http://localhost/silverstripe/player does not work.
TeamController.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'
Why are the routes not working?
Upvotes: 1
Views: 649
Reputation: 761
Transfer this to a routes.yml
Director:
rules:
'teams//$Action/$ID/$Name': 'TeamController'
'player/': 'PlayerController'
'': 'HomeController'
Upvotes: 2