1

コントローラーでは、Web サービスからニュースの配列を取得してい $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 のドキュメントに示されているようにデフォルトのページネーション方法を試しましたが、うまくいきませんでした。アドバイスありがとう

4

1 に答える 1

1

することができcopy cake/Controller/Component/PaginatorComponent.phpapp/Controller/Component/PaginatorComponent.phpその中の paginate 関数をオーバーライドします。単純な変更により、配列ページネーターがあります。

于 2012-09-06T04:07:29.807 に答える