Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Dedicated server web hosting provided by Guru-host.eu.
New Pagination Issue

 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
ucntkilme
Smarty Regular


Joined: 03 Sep 2007
Posts: 84

PostPosted: Thu Oct 23, 2008 9:12 pm    Post subject: New Pagination Issue Reply with quote

Got pagination to work the way I wanted -- hence the topic below this (pagination woes) being solved..

However, in my template file when I put:

Items {$paginate.first}-{$paginate.last} out of {$paginate.total} displayed.

All that comes out is: Items - out of displayed.

http://www.rvwebhosting.com/newsite/index.php?pg=portfolio

I read the helpfile and it doesnt say anything about it except just using that code (which is where I got it)...

here is my code:

Code:

<?php
case portfolio:
      // required connect
       SmartyPaginate::connect();
       // set items per page
       SmartyPaginate::setLimit(10);
      //      $_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM my_table LIMIT %d,%d",
      //          SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());
      $data = $aws->get_db_results();
      $page = 'portfolio.tpl';
      $aws->assign('data', $data);
   break;
?>


then the function get_db_results():

Code:

<?php
function get_db_results() {
   
        $_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM portfolio ORDER BY p_id DESC LIMIT %d,%d",
            SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());
       
        $_result = mysql_query($_query);

        while ($_row = mysql_fetch_array($_result, MYSQL_ASSOC)) {
            // collect each record into $_data
            $_data[] = $_row;
        }
       
        // now we get the total number of records from the table
        $_query = "SELECT FOUND_ROWS() as total";
        $_result = mysql_query($_query);
        $_row = mysql_fetch_array($_result, MYSQL_ASSOC);
       
        SmartyPaginate::setTotal($_row['total']);

        mysql_free_result($_result);
       
        return $_data;

    }
?>


Have I done something wrong?
Back to top
View user's profile Send private message
ucntkilme
Smarty Regular


Joined: 03 Sep 2007
Posts: 84

PostPosted: Thu Oct 23, 2008 9:49 pm    Post subject: Reply with quote

This was figured out...

basically I started looking at the class file for SmartyPaginate and noticed the function called Assign -- so I started working with that... put into my php file

SmartyPaginate::assign($aws);

but it kept giving me errors... i started searching google for SmartyPaginate::assign and found some information on it -- some suggestions none of them worked...

But, when I went back to the class file, and changed the name for the function to assigns and changed it in my php file to:

SmartyPaginate::assigns($aws);

it works without a problem.

Though I do have a question for anyone who might know...

{paginate_middle} gives me stuff like [1-10][11-14] (current on my site) -- has anyone figured out a way to show only page numbers instead?

Or morht, if you have some insight on this -- it would be very appreciated to get some info on maybe what to edit with what to just show page numbers instead of the 1-10, 11-14.

If I can get info on it and such, i'll write a new function for it so that people could then use {paginate_middle} for the standard and {paginate_pages} for the page numbers or something.

Thanks.
Back to top
View user's profile Send private message
weblink
Smarty Rookie


Joined: 03 Apr 2010
Posts: 12

PostPosted: Tue Apr 13, 2010 5:25 am    Post subject: try this Reply with quote

Code:
{paginate_middle  format="page"}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP