2
什麼是限制CMS用戶創建3級子頁面的最簡單方便的方法?SilverStripe限制3級子頁面
我在class Page
public function canHaveChild() {
//Get SiteTree column value ParentID of this record
$parentID = DataObject::get("SiteTree", "WHERE ID = '$this->ID'")->ParentID;
//If parentID = 0, this is a root page, so it can have a childpage
if($parentID == 0) {
$this->allowed_children = array("Page", "BasicPage", "FormPage");
} else {
$this->allowed_children = false;
}
}
使用此功能試過,我仍然可以創建子頁面遠了樹,所以它不會改變allowed_children
完美使用'$ this-> Level(2)' – Faloude