1
SilverStripe Docs에 묘사 된 표면적 인 것처럼, 내 홈페이지에 대한 사용자 정의 컨트롤러를 설정하려고합니다.빈 경로가 404 오류로 이동합니다. - SilverStripe 3.5
기본 홈페이지 링크를 'custom-home'으로 변경하고 두 경로를 추가했습니다. 경로가있는 두 번째 것은 작동하고 내 컨트롤러로 안내합니다. 첫 번째 (비어있는) 사람은 나를 404 오류 페이지로 보냅니다.
해결 방법을 찾을 수 없습니다. 어떤 제안?
routes.yml
Director:
rules:
'': 'MyHome_Controller'
'custom-home': 'MyHome_Controller
_config.php
RootURLController::set_default_homepage_link('custom-home');
MyHome_Controller.php
<?php
class MyHome_Controller extends Page_Controller {
private static $allowed_actions = [];
private static $url_handlers = [];
public function init() {
parent::init();
}
public function Link($action = null) {
return Director::baseURL() . 'custom-home';
}
public function index() {
$data = [
'Title' => 'Hello World',
'ClassName' => __CLASS__,
];
return $this
->customise($data)
->renderWith([__CLASS__, 'Page']);
}
}
문제는 페이지가 아닙니다. 그냥 컨트롤러 –
SPA 용입니까? 모든 경로가 클라이언트 측에서 처리되고 있습니까? – UncleCheese
SPA = 단일 페이지 신청? 주로 제어기로 접근 가능한 페이지를 만들고 싶은 웹 사이트를 대상으로하는 테스트입니다. 데이터베이스 항목이 없으므로 CMS를 통해 해당 특수 페이지를 관리 할 수 없습니다. –