Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Paginate Template Functions

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
jasonx
Smarty Rookie


Joined: 04 Feb 2005
Posts: 11

PostPosted: Fri Feb 04, 2005 6:26 am    Post subject: Paginate Template Functions Reply with quote

Hi,

I am new to smarty and new to Smarty Paginate.

I have everything working fine in terms of the offset for the mysql queries etc.

What I have a problem with are links such as

messaging.php?view=inbox

Can I make the standard {paginate_prev/middle/next}) automatically pull back the variables and data in the URL?

My links atm become
message.php?next=1 etc

Thanks
Jason
Back to top
View user's profile Send private message
thiebo
Smarty Pro


Joined: 16 Jan 2005
Posts: 144
Location: Paris

PostPosted: Fri Feb 04, 2005 7:26 am    Post subject: Reply with quote

Hi,

Would this be a solution ?

http://smarty.php.net/manual/en/language.variables.smarty.php

If you have your pagination functionning with a database query may I please see your code, I have some minor problems getting it all to work fine.

Thiebo
Back to top
View user's profile Send private message Visit poster's website
jasonx
Smarty Rookie


Joined: 04 Feb 2005
Posts: 11

PostPosted: Fri Feb 04, 2005 11:53 am    Post subject: Reply with quote

Code:

  $result = $connector->query('SELECT users.username,
                                      sender.username,
                                      messages.id,
                                      messages.senderid,
                                      messages.title,
                                      messages.body,
                                      messages.sent,
                                      messages.sent,
                                      messages.folder,
                                      messages.read,
                                      messages.replyid
                                 FROM messages
                           INNER JOIN users
                                   ON messages.userid = users.id
                           INNER JOIN users AS sender
                                   ON messages.senderid = sender.id
                                WHERE users.id='.$_SESSION['userid'].'
                                  AND messages.folder=0
                             ORDER BY messages.sent
                                 DESC
                                LIMIT '.SmartyPaginate::getCurrentIndex().','.SmartyPaginate::getLimit());

  $return_array = array();
  while ($row = $connector->fetchArray($result)){
    array_push($return_array, $row);
  }

  SmartyPaginate::setTotal($inbox_result);

  $_data = array_slice($return_array, SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());


  $smarty->assign('results', $_data);

  $smarty->assign('messages',$return_array);
  $smarty->display('messaging.tpl');



This is my code for one of my sections. The other sections are similar.

$inbox_result is just getNumRows for the same query without the offset. I had to run this query anyways due to including the amount of messages in the template as Inbox(5).

Code:

             <table border="0" cellspacing="0" cellpadding="2" width="100%">
                    <tr bgcolor="#CCCC99">
                          <td></td>
                          <td>from</td>
                          <td>subject</td>
                          <td>sent</td>
                    </tr>
                    {section name=i loop=$messages}
                    <tr bgcolor="{cycle values="#CCCCCC,#E5E5E5"}">
                          <td>{if $messages[i].read eq 0}
                          {html_image file="templates/messages/new.gif"}
                          {else}
                          {html_image file="templates/messages/read.gif"}
                          {/if}
                          </td>
                          <td><a href="profile/{$messages[i].username}">{$messages[i].username}</a></td>
                          <td><a href="?action=view&id={$messages[i].id}"><b>{if $messages[i].replyid neq 0}RE: {/if}{$messages[i].title}</b></a></td>
                          <td>{$messages[i].sent|date_format:"%a, %b %e, %Y - %I:%M%p"}</td>
                    </tr>
                    {/section}
              </table>
{paginate_prev} {paginate_middle} {paginate_next}

That's basically my template. How do I modify the links for {paginate_prev} {paginate_middle} {paginate_next} ? I went quickly over the read me file and I think I need to create my own custom navigation. But I thought I could just easily do something to the standard template navigation links.
Back to top
View user's profile Send private message
jasonx
Smarty Rookie


Joined: 04 Feb 2005
Posts: 11

PostPosted: Fri Feb 04, 2005 12:50 pm    Post subject: Reply with quote

I've just split the file into smaller files now so I don't need action=viewsent etc. But I wouldn't mind how to do this in the future.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons 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