【问题标题】:Paginate array (not from DB) cakePHP分页数组(不是来自数据库) cakePHP
【发布时间】:2012-08-29 19:33:25
【问题描述】:

在控制器中,我从网络服务$news = json_decode(@file_get_contents($submenu), true); 获得了一系列新闻,我需要将此数组分页为每页 6 个新闻。我的数组结构:

array(
    (int) 0 => array(
        'id' => '716',
        'city_id' => null,
        'language' => 'lit',
        'header' => 'Lorem ipsum dolor sit amet.',
        'description' => '<p>Sed  diam  nonummy nibh euismod tincidunt ut laoreet dolore magna.',
        'short_description_img' => '',
        'autor' => 'Avio',
        'friendly_link' => 'Lorem_ipsum_dolor_sit_amet_1346393036',
        'created' => '2012-08-31 09:03:56',
        'general_tag' => array(
            'id' => null,
            'agency_id' => null,
            'project_id' => null,
            'active' => null,
            'language' => null,
            'title' => null,
            'friendly_link' => null,
            'healthcare_trip_tag' => null,
            'created' => null
        ),
        'tags' => array()
    )
        (int) 1 => array(
        'id' => '717',
        'city_id' => null,
        'language' => 'lit',
        'header' => 'Lorem ipsum dolor sit amet.',
        'description' => '<p>Sed  diam  nonummy nibh euismod tincidunt ut laoreet dolore magna.',
        'short_description_img' => '',
        'autor' => 'Avio',
        'friendly_link' => 'Lorem_ipsum_dolor_sit_amet_1346393036',
        'created' => '2012-08-31 09:03:56',
        'general_tag' => array(
            'id' => null,
            'agency_id' => null,
            'project_id' => null,
            'active' => null,
            'language' => null,
            'title' => null,
            'friendly_link' => null,
            'healthcare_trip_tag' => null,
            'created' => null
        ),
        'tags' => array()
    )
         .................
)

尝试了 CakePHP 文档中显示的默认分页方法,但没有成功。谢谢建议

【问题讨论】:

    标签: cakephp cakephp-2.0 cakephp-2.1 pagination cakephp-2.2


    【解决方案1】:

    你可以 copy cake/Controller/Component/PaginatorComponent.php 到 app/Controller/Component/PaginatorComponent.php ,然后覆盖其中的分页函数。 通过简单的更改,您就有了数组分页器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-19
      • 1970-01-01
      • 1970-01-01
      • 2016-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多