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

How to paginate {section/}
Goto page Previous  1, 2
 
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 -> Tips and Tricks
View previous topic :: View next topic  
Author Message
teknon
Smarty Rookie


Joined: 13 May 2006
Posts: 6

PostPosted: Thu May 18, 2006 6:48 am    Post subject: Re: How to paginate {section/} Reply with quote

mphare wrote:
Hi,
I've looked at {section} and see good things like 'start' and 'max' parameters. Seems like it should be possible to limit {section} to display, say 30 things, then have a button or link to get the next or previous 30 things.

But I don't see how to do it. Smarty is a bit of black-magic to me as I have only been using it for about 6 hours now.

Anyone have a cool tip or trick to do pagination with {selection} loops?

Thanks,

Mike



Did you ever find out how to do this. I would love to know how.
Back to top
View user's profile Send private message
ade.dedot
Smarty n00b


Joined: 31 Aug 2006
Posts: 1

PostPosted: Thu Aug 31, 2006 10:38 am    Post subject: Reply with quote

hi all, i'm new to smarty, and right now i have a task to paginate the site that i've built, here is my php code:

Code:


<?

   define('DIR', dirname(__FILE__) );
   require (DIR.'/lib/smarty/Smarty.class.php');
    $smarty = new Smarty();

    $smarty->template_dir = DIR.'/templates/';
    $smarty->compile_dir =  DIR.'/templates_c/';
    $smarty->config_dir =  DIR.'/configs/';
    $smarty->cache_dir =  DIR.'/cache/';

   include ('db.inc.php');

   $sort = $_GET['sort'];

   if ($sort == 'date'){
      $SQL = "SELECT * FROM news ORDER BY date DESC";
   }else{
      $SQL = "SELECT * FROM news ORDER BY id DESC";
   }

   $result = mysql_query($SQL) or die ('Query failed: ' . mysql_error());
   while($rs = mysql_fetch_object($result)){
       $dispData[] = $rs;
    }

/*
    var_dump($dispData1);
    var_dump($dispData2);
*/

   $smarty->plugins_dir[] = 'includes/my_smarty_plugins';
    $smarty->assign('dispData',$dispData);
    $smarty->display('index_admin_news.tpl');

?>



and this is my tpl:
Code:


{include file = 'gw_head_admin.tpl'}

<title>ADMIN</title>
<h1>ADMINISTRATOR PAGE!</h1>

<style>
.tablebg{ldelim}
   background-color:#99CCFF;
   border:4px solid #567;
{rdelim}

.tablecell{ldelim}
   background-color:#FFFCCC;
   border:1px solid #0F0;
{rdelim}
</style>

<pre><a href="index_admin.php">Home</a>      <a href="index_admin_news.php">News</a>      <a href="index_admin_artikel.php">Artikel</a>      <a href="index_admin_module.php">Module</a></pre>

<P></p>

<p><a href ="admin_new_news.php">Neue News</a></p>
<table border="1">
    <tr class="tablebg">
        <td>  </td>
        <td><a href="index_admin_news.php?sort=id">ID  </a></td>
        <td>Headline</td>
        <td>Teaser</td>
        <td>Teaser1</td>
        <td>Content</td>
        <td>Quelle</td>
      <td><a href="index_admin_news.php?sort=date">Date</a></td>
    </tr>
    {foreach key=key item=news from=$dispData}
    <tr class="tablecell" >
        <td><a href="admin_update_news.php?id={$news->id}">Bearbeiten </a></td>
        <td>{$news->id}</td>
        <td>{$news->headline}</td>
        <td>{$news->teaser|truncate:120}</td>
        <td>{$news->teaser1}</td>
        <td>{$news->content|truncate:120}</td>
        <td>{$news->quelle|truncate:40}</td>
   <td>{$news->date}</td>
    </tr>
    {/foreach}
</table>



i've tried several example code from different sources, but none of them worked, could anybody please help me?

thanks in advance
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 -> Tips and Tricks All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
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