Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
echo $pagination; returns empty div
  • // invoices.php
        public function action_index() {
    $count = Model_Invoice::count();
    $per_page = 20;

    $config = array(
    'pagination_url' => \Fuel\Core\Uri::base(false) . 'admin/invoices/index/page/',
    'total_items' => $count[0]['num_entries'],
    'per_page' => $per_page,
    'uri_segment' => 5,
    );

    $pagination = Pagination::forge('invoice_pagination', $config);

    $data['invoices'] = Model_Invoice::find('all', array(
    'limit' => $pagination->per_page,
    'offset' => $pagination->offset,
    'order_by' => array(
    'created_at' => 'desc',
    ),
    ));
    //...
    $this->template->content = View::forge('admin/invoices/index', $data)->set('pagination', $pagination, false);
    }


    // the view:
    <?php echo $pagination; ?>

    // result:
    <div class="pagination">

    </div>


    My pagination works on other pages, but it's empty here. What on earth is going on? The pages work, admin/invoices/index/page/# loads the correct data for the page.


    print_r($pagination) in the controller returns:
    Fuel\Core\Pagination Object
    (
    [config:protected] => Array
    (
    [current_page] =>
    [offset] => 0
    [per_page] => 20
    [total_pages] => 0
    [total_items] => 0
    [num_links] => 5
    [uri_segment] => 5
    [show_first] =>
    [show_last] =>
    [pagination_url] => ...removed.../archive/admin/invoices/index/page/
    [link_offset] => 0.5
    [calculated_page] => 1
    )

    [template:protected] => Array
    (
    [wrapper] => <div class="pagination">
    {pagination}
    </div>

    [first] => <span class="first">
    {link}
    </span>

    [first-marker] => ««
    [first-link] => <a href="{uri}">{page}</a>

    [first-inactive] =>
    [first-inactive-link] =>
    [previous] => <span class="previous">
    {link}
    </span>

    [previous-marker] => «
    [previous-link] => <a href="{uri}" rel="prev">{page}</a>

    [previous-inactive] => <span class="previous-inactive">
    {link}
    </span>

    [previous-inactive-link] => <a href="#" rel="prev">{page}</a>

    [regular] => <span>
    {link}
    </span>

    [regular-link] => <a href="{uri}">{page}</a>

    [active] => <span class="active">
    {link}
    </span>

    [active-link] => <a href="#">{page}</a>

    [next] => <span class="next">
    {link}
    </span>

    [next-marker] => »
    [next-link] => <a href="{uri}" rel="next">{page}</a>

    [next-inactive] => <span class="next-inactive">
    {link}
    </span>

    [next-inactive-link] => <a href="#" rel="next">{page}</a>

    [last] => <span class="last">
    {link}
    </span>

    [last-marker] => »»
    [last-link] => <a href="{uri}">{page}</a>

    [last-inactive] =>
    [last-inactive-link] =>
    )

    [raw_results:protected] => Array
    (
    )

    )
  • HarroHarro
    Accepted Answer
    Total items and total pages is zero, so there is nothing to pagina. Pagination only outputs something if there are at least two pages.

    The issue is probably with 

    $count[0]['num_entries']
    as count() returns an integer?
  • OMG, thank you. Need more coffee. T_T
  • Always a solution: more coffee... :-)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion