Customising totals and page navigation at the bottom of lists

chozma

Member
Hi all,

I would really appreciate some pointers on how to customise the totals and page navigation elements at the bottom of a list.

To start with I would like to be able to move these elements to display at the top of a list, rather than the bottom. But I can't work out in the list view template files where this code gets generated... :( I think it might be something to do with the pagination file, but I don't really get how this is called or works.

Any pointers would be appreciated.

Many thanks,

Hannah
 
You can't really do much by way of "customization" of the page navigation, as it's created as a single monolithic entity ($this->nav), generated in our core code, which is placed in a <tfoot>, around line 66 in the default.php of the standard bootstrap template. You could probably change that to a <thead>. And you could apply CSS styling in a custom CSS to change the look and feel. But you won't be able to make any actual markup changes.

You have a little more leeway with the calculations, which are inserted in another tfoot starting around line 126.

So yes. Copy the default template, and start tweaking default.php.

-- hugh
 
Awesome, that's really helpful thanks Hugh. Its in <thead> now and works a treat.

Is there anyway I could grab the total figure for use elsewhere on the page? I had come up with some code that kinda works
Code:
echo ($this->rows[0][0]->total);
but if you start grouping the results it breaks so I guess the code isn't as bulletproof as I'd like. Is there another natty way I can use that total figure as its already been calculated and I don't really want to have to calculate it again using SQL queries if I can avoid it.

Thanks again, Hannah x
 
Remember that var_dump() is your friend. So typically if you are trying to work out what is where in our data structures at any given point, just dump the data structure. So where you currently have that line of code ...

Code:
var_dump($this->rows);exit;

... should help you figure out what is where.

That's pretty much what I do when answering questions like this, as I can never remember off the top of my head what's where during list rendering. Although typically I would use xdebug in Eclipe and step through the code and examine the variables that way, but same principle.

-- hugh
 
Thanks Hugh. I've been playing around with var_dump today and have managed to see how the list changes when it is grouped or not. Very useful pointer! :)

For anyone that's interested here's the code I have written that displays the total number of records in a list

Code:
<?php
//need to make sure the list is not empty first
if ($this->rows) :
    //works out what the first key name is
    //as it can be different depending on if the list is grouped or not for example
    $firstKeyName = array_keys($this->rows); ?>
 
    <div class="total">
        <h4>There are
            <?php //puts in the first element's key name
            echo ($this->rows[$firstKeyName[0]][0]->total); ?>
            item(s) in total
        </h4>
    </div>
<?php endif; ?>
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top