2

我一直在查看本教程,将一个简单的页面添加到 Silverstripe (3.0.5) 的管理区域,但在 apache 日志中出现分段错误错误。

我认为问题在于“customHelp.php”中的“index”方法 - 当我将“index”重命名为其他名称时,我没有崩溃,并且在管理菜单中出现了一个条目,但是当我单击它时显然没有显示任何内容.

这是我的“customHelp.php”的内容 - 有人可以指出我正确的方向吗?

<?php

class customHelp extends LeftAndMain { 

    static $url_segment = "customHelp"; 
    static $menu_title = "Site Help";     
    static $allowed_actions = array ('customHelp'); 

    public function index() { 
        return $this->renderWith('customHelp'); 
    }     

    public function init() { 
        parent::init(); 
    }
}
4

2 回答 2

0

I guess the tutorial is not correct or outdated.

I tried it here and got the error:

Declaration of customHelp::index() should be compatible with that of LeftAndMain::index()

So making it compatible for overiding with:

public function index($request) { 
    return $this->renderWith('customHelp'); 
} 

made it work here.

于 2013-04-26T16:49:03.620 回答
-1

可能不相关,但您应该在类名中使用正确的命名约定,即使指南另有建议:

类应以大写字母http://doc.silverstripe.org/framework/en/trunk/misc/coding-conventions开头,文件名应遵循此。

在将文件提供为区分大小写的服务器上运行时,您可能会遇到问题。

编辑:

只是打我,索引问题可能是由未刷新的模板缓存引起的:在站点上运行 ?flush=all 。

于 2013-04-23T15:09:15.357 回答