我在mysite的/代码/ page.php文件一个以下内容:访问Silverstripe页要求
...
class Page_Controller extends ContentController {
public function init() {
parent::init();
Requirements::javascript("themes/example/js/global1.js");
Requirements::javascript("themes/example/js/global2.js");
Requirements::javascript("themes/example/js/global3.js");
}
}
...
,然后在mysite的/控制器定制控制器/ PlayController.php:
...
class PlayController extends ContentController {
public function init() {
parent::init();
Requirements::javascript("themes/example/js/play.js");
}
}
...
我想在PlayController.php中使用Page.php的要求。既然他们都延伸ContentController
,这可能吗?
有点背景; PlayController
用于使用Layout/PlayPage.ss模板显示剧院播放的页面。如果我将这些需求放在templates/Page.ss中,它们会被PlayPage.ss继承。但是我想将这些需求放在一个控制器中,所以我可以使用Silverstripe的combine_files
功能。希望这是有道理的!
感谢:-)
两个很好的解决方案,非常感谢! – SalutBarbu