如何修改 Silverstripe 3.2 中 DataList 的阶段 (Stage/Live)?
How do you modify the stage (Stage/Live) of a DataList in Silverstripe 3.2?
有谁知道如何在 Silverstripe 3.2 中修改 DataList 的阶段?我想修改我的网格字段组件中的 DataList 以根据 ?_GET['stage'] 参数进行更改。
我像下面这样解决了这个问题。
class GridFieldChangeStage implements GridField_DataManipulator {
/*
* Modifies the DataList stage accordingly
*/
public function getManipulatedData(GridField $gridField, SS_List $dataList)
{
$isShowingLiveData = (isset($_GET['stage']) && $_GET['stage'] == 'Live');
if ($isShowingLiveData) {
$dataList = $dataList->alterDataQuery(function($dataQuery) {
$dataQuery->setQueryParam('Versioned.mode', 'stage');
$dataQuery->setQueryParam('Versioned.stage', 'Live');
});
}
return $dataList;
}
}
有谁知道如何在 Silverstripe 3.2 中修改 DataList 的阶段?我想修改我的网格字段组件中的 DataList 以根据 ?_GET['stage'] 参数进行更改。
我像下面这样解决了这个问题。
class GridFieldChangeStage implements GridField_DataManipulator {
/*
* Modifies the DataList stage accordingly
*/
public function getManipulatedData(GridField $gridField, SS_List $dataList)
{
$isShowingLiveData = (isset($_GET['stage']) && $_GET['stage'] == 'Live');
if ($isShowingLiveData) {
$dataList = $dataList->alterDataQuery(function($dataQuery) {
$dataQuery->setQueryParam('Versioned.mode', 'stage');
$dataQuery->setQueryParam('Versioned.stage', 'Live');
});
}
return $dataList;
}
}