dongshu4755 2015-08-20 13:37
浏览 21

SilverStripe PaginatedList抛出异常

I'm using 3.1.13 SilverStripe CMS and Framework. I have ran into troubles after creating a function inside my Page.php (class Page) and initializing it in my views (page.ss). I want to create a pagination for my project. Here is my error with source and trace:

[User Error] Uncaught Exception: The request must be readable as an array.
GET /?flushtoken=88455a3cc5497ee38dd7a61d75370221&flush=all

Line 28 in /var/www/project-name/framework/core/PaginatedList.php


Source

19   * Constructs a new paginated list instance around a list.
20   *
21   * @param SS_List $list The list to paginate. The getRange method will
22   *        be used to get the subset of objects to show.
23   * @param array|ArrayAccess Either a map of request parameters or
24   *        request object that the pagination offset is read from.
25   */
26  public function __construct(SS_List $list, $request = array()) {
27      if (!is_array($request) && !$request instanceof ArrayAccess) {
28          throw new Exception('The request must be readable as an array.');
29      }
30 
31      $this->request = $request;
32      parent::__construct($list);
33  }
34 


Trace

PaginatedList->__construct(DataList,)
HomePage.php:182
HomePage->PaginatedPages()
call_user_func_array(Array,Array)
Object.php:731
Object->__call(PaginatedPages,Array)
ViewableData.php:361
HomePage_Controller->PaginatedPages()
ViewableData.php:361
ViewableData->obj(PaginatedPages,,1,,)
SSViewer.php:91
SSViewer_Scope->getObj(PaginatedPages,,1,,)
SSViewer.php:504
SSViewer_DataPresenter->getObj(PaginatedPages,,1,,)
SSViewer.php:111
SSViewer_Scope->obj(PaginatedPages,,1)
.cache.themes.project-name.templates.Layout.HomePage.ss:400
include(/tmp/silverstripe-cache-php5.5.9-1ubuntu4.11-var-www-project-name/www-data/.cache.themes.project-name.templates.Layout.HomePage.ss)
SSViewer.php:1031
SSViewer->includeGeneratedTemplate(/tmp/silverstripe-cache-php5.5.9-1ubuntu4.11-var-www-project-name/www-data/.cache.themes.project-name.templates.Layout.HomePage.ss,HomePage_Controller,,Array,)
SSViewer.php:1098
SSViewer->process(HomePage_Controller,)
SSViewer.php:1094
SSViewer->process(HomePage_Controller)
Controller.php:203
Controller->handleAction(SS_HTTPRequest,index)
RequestHandler.php:200
RequestHandler->handleRequest(SS_HTTPRequest,DataModel)
Controller.php:153
Controller->handleRequest(SS_HTTPRequest,DataModel)
ContentController.php:198
ContentController->handleRequest(SS_HTTPRequest,DataModel)
ModelAsController.php:78
ModelAsController->handleRequest(SS_HTTPRequest,DataModel)
RootURLController.php:130
RootURLController->handleRequest(SS_HTTPRequest,DataModel)
Director.php:370
Director::handleRequest(SS_HTTPRequest,Session,DataModel)
Director.php:153
Director::direct(/,DataModel)
main.php:177

Where is the problem? I'm following this instructions and it fails when I'm calling my function in the view.

  • 写回答

1条回答 默认 最新

  • doujiao3016 2015-08-20 13:47
    关注

    Nevermind! I just realized that if I want to get $this->request work, I need to place that function into class Page controller.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度