|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
jasonx Smarty Rookie
Joined: 04 Feb 2005 Posts: 11
|
Posted: Fri Feb 04, 2005 6:26 am Post subject: Paginate Template Functions |
|
|
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 |
|
thiebo Smarty Pro
Joined: 16 Jan 2005 Posts: 144 Location: Paris
|
|
Back to top |
|
jasonx Smarty Rookie
Joined: 04 Feb 2005 Posts: 11
|
Posted: Fri Feb 04, 2005 11:53 am Post subject: |
|
|
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 |
|
jasonx Smarty Rookie
Joined: 04 Feb 2005 Posts: 11
|
Posted: Fri Feb 04, 2005 12:50 pm Post subject: |
|
|
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 |
|
|
|
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
|