missing pagination in list generated by elgg_view_entity_list

i am creating a page that renders a standard list of entities from a pre-existing array of entities here.

i have used the code:
            $options = array(
            'offset' => max(get_input('offset'), 0),
            'limit' => 10,
            'full_view' => false,
            'list_type' => 'list',
            'pagination' => true,
        $content = elgg_view_entity_list($entity_list, $options);


i am seeing that there is no pagination rendered, just one large list (no size limit is applied either)..
anyone know why that may be?

  • I believe pagination requires a 'count' parameter

  • ah ok, thanks.. i'll have a look at that option then.

  • according to: http://reference.elgg.org/views_8php_source.html#l00992

    the count variable is for pre 1.8 functions and is deprecated.. so that's not the cause here.

  • Count as the second argument of the function is deprecated, count as a key of an array of parameters is not :)

  • looking through the source for list.php i see:
     * @uses $vars['limit']       Number of items per page. Only used as input to pagination.
     * @uses $vars['count']       Number of items in the complete list

    so 'count' is the total size of the list (which is really an overall limit) and 'limit' is the page size.


    so far i have not been able to cause the pagination to render via changing these variables to different values. e.g.

    $content = elgg_view_entity_list($entity_list, '', max(get_input('offset'), 0),10,false,false,true);

    (or by using the 2nd optional parameter of $vars)


  • @ura soul You need use 'count' in array of your $entity_list else need to set it in $options.

    See http://reference.elgg.org/views_8php_source.html#l01006

  • Also see on working code:

    $content = elgg_view_entity_list($entity_list, array(
            'count' => $count,
            'offset' => $offset,
            'limit' => 10,
            'full_view' => false,
            'list_type' => 'list',
            'pagination' => true,

  • thanks for assisting.

    i have used the following code and now the pagination is rendered, yet each page of the list contains all the items in the list (so each page of the list is 79 items long instead of 10 and 8 pages are shown for the pagination):

            $content = elgg_view_entity_list($entity_list,array(
                'count' => count($entity_list),
                'offset' => max(get_input('offset')),
                'limit' => 10,
                'full_view' => false,
                'list_type' => 'list',
                'pagination' => true));


  • You shouldn't be passing 79 entities to the list, you should only be passing the 10 you want to display

  • aha!

    so now the code works with:

            $offset = (int) max(get_input('offset', 0), 0);
            $length = 10;
            $content = elgg_view_entity_list(array_slice($entity_list,$offset,$length),array(
                'count' => count($entity_list),
                'full_view' => false,
                'list_type' => 'list',
                'pagination' => true),$offset, $length);