1

In controller I'm getting array of news from web-service $news = json_decode(@file_get_contents($submenu), true); and I need to paginate this array to 6 news per page. My array's structure:

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()
    )
         .................
)

Tried default pagination method as shown in CakePHP documentation but no luck. Thanks for advices

1 Answer 1

1

you can copy cake/Controller/Component/PaginatorComponent.php to app/Controller/Component/PaginatorComponent.php , then override the paginate function in it. By Simple changes you have array paginator.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.