2
作爲一項練習,以幫助我瞭解如何編寫自定義報告,我寫了一個非常簡單的自定義報告按頁面類型列出頁面。我寫了基於標準的報告CMS /代碼/報告的代碼/ BrokenLinksReport.php(包括作爲CMS的一部分),但我得到一個錯誤:爲什麼我的自定義SS3.1報告返回錯誤「[注意]類GridState_Data的對象無法轉換爲int」
[Notice] Object of class GridState_Data could not be converted to int
我甩的$的數據,以確保它是內容如預期的那樣,事實如此。什麼可能導致這個問題?
我的代碼如下:
class PageListByType extends SS_Report {
function title() {
return "Page List by Type";
}
function description() {
return "List all the pages in the site, along with their page type";
}
public function sourceRecords($params = array(), $sort = null, $limit = null) {
$data = Page::get()->sort($sort);
$returnSet = new ArrayList();
if ($data) foreach ($data as $record) {
$returnSet->push($record);
}
return $returnSet;
}
public function columns() {
return array(
array(
'title'=>_t('PageListByTypeReport.PageName', 'Page name')
),
array(
'className'=>_t('PageListByTypeReport.ClassName', 'Page type')
)
);
}
}
謝謝!有興趣知道原因。與此同時,你的代碼是一種享受! :-) –
我已經用我發現的內容更新了我的答案。我希望這個問題是有道理的。 – 3dgoo