Styling the paging feature

0

For the project I'm currently working on I wanted a slightly more functional paging than the one that comes with the plugin. You can see a snapshot of the result here: http://www.fidusabikes.com/wp-content/uploads/Snapshot-2009-09-23-14-26-05.png

If you like the result you can follow the below steps. Notice that for this to work you'll have to change a pod file.

a. I first created a file named pagination_2.php inside the pod plugin installation folder containing the following code (copy&paste):

<pre> <?php $page = $this->page; $rows_per_page = $this->rpp; $total_rows = $this->getTotalRows(); $total_pages = ceil($total_rows / $rows_per_page); $type = $this->datatype;

$request_uri = "?type=$type&"; foreach ($_GET as $key => $val) { if ('pg' != $key && 'type' != $key && !empty($val)) { $request_uri .= $key . '=' . urlencode($val) . '&'; } } ?> <div class="podPager"><?php

    if($total_pages > 1) :
        echo '<span class="pages">'.$label1.' '.$page.' '.$label2.' '.$total_pages.':</span>';
    endif; 

    if (1 < $page) :
        if($total_pages > 2) : 
            echo ' <a href="'.$request_uri.'pg=1" class="firstPage">&laquo; '.$label3.' ... </a>';
        else : 
            echo ' <a href="'.$request_uri.'pg=1" class="pageNum firstPage">1</a>';
        endif;
    endif; 

    if (1 < ($page - 100)) :
        echo ' <a href="'.$request_uri.'pg='.($page - 100).'" class="pageNum">'.($page - 100).'</a>';
    endif;

    if (1 < ($page - 10)) :
        echo ' <a href="'.$request_uri.'pg='.($page - 10).'" class="pageNum">'.($page - 10).'</a>';
    endif; 

    for ($i = 4; $i > 0; $i--) : 
        if (1 < ($page - $i)) : 
            echo ' <a href="'.$request_uri.'pg='.($page - $i).'" class="pageNum">'.($page - $i).'</a>';
        endif;
    endfor;

    ?> <span class="pageNum currentPage"><?php echo $page; ?></span><?php

    for ($i = 1; $i < 5; $i++) :
        if ($total_pages > ($page + $i)) :
            echo ' <a href="'.$request_uri.'pg='.($page + $i).'" class="pageNum">'.($page + $i).'</a>';
        endif;
    endfor;

    if ($total_pages > ($page + 10)) : 
        echo ' <a href="'.$request_uri.'pg='.($page + 10).'" class="pageNum">'.($page + 10).'</a>';
    endif;

    if ($total_pages > ($page + 100)) :
        echo ' <a href="'.$request_uri.'pg='.($page + 100).'" class="pageNum">'.($page + 100).'</a>';
    endif; 

    if ($page < $total_pages) : 
        if($total_pages > 2) :
            echo ' <a href="'.$request_uri.'pg='.$total_pages.'" class="lastPage"> ... '.$label4.' &raquo;</a>';
        else:
            echo ' <a href="'.$request_uri.'pg='.$total_pages.'" class="pageNum">2</a>';
        endif;
    endif;

    ?>
</div>

</pre>

b. I then added to my stylesheet the following:

<pre> /* Pod Paging -------------------------------------------------------------- */ .podPager {padding:1.5em;overflow:hidden;border-top:1px solid #eee;background:#f6f6f6;color:#666;margin-bottom:1.5em;} .pageNum {padding:0 5px;} .currentPage {background:#ccc;color:#fff;} </pre>

c. Then I opened Pod.class.php file and changed the line 674 to:

<pre> function getPagination($label1 = 'Page', $label2 = 'of', $label3 = 'First', $label4 = 'Last') </pre>

d. To display the paging I added to my template:

<pre> <?php echo $Record->getPagination('??????', '???', '?????', '?????????');?> </pre>

So now I have anice looking paging in Greek. Obviously you can use in getPagination your own language or simply use getPagination() for English.

asked Sep 24 '09 at 2:53

nikos

25

add comment
enter at least 15 characters

2 Answers

0

Apologies for the double posting it.

answered Sep 23 '09 at 12:44

nikos

25

add comment
enter at least 15 characters
0

Hi,

This is a good improvement, indeed. Thanks for sharing this. I love this and I have tried and done some improvement in my blog.

http://www.openscriptsolution.com/2009/09/24/improving-pagination-feature-in-pods-cms-of-wordpress/

Hope it is helpful. Cheers!

answered Sep 24 '09 at 2:53

Masino Sinaga

41

add comment
enter at least 15 characters