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

Stronicowanie w Smartach - Paginacja

 
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 -> Language: Polish
View previous topic :: View next topic  
Author Message
ma_po
Smarty Rookie


Joined: 09 Jul 2008
Posts: 5

PostPosted: Thu Jul 10, 2008 7:56 am    Post subject: Stronicowanie w Smartach - Paginacja Reply with quote

Witam, mam problem z classą SmartyPaginate.class.php służącą do stronicowania.

Classa sama w sobie działa, pojawiają się ilość elementów i jest stronicowanie, ale nie wyświetlają mi się zawartość danych która ma się wyświetlać.

Mam kod testowy:

<?php
session_start();
include ("../../smarty/libs/Smarty.class.php");
include ("../../smarty/libs/SmartyPaginate.class.php");

$smarty =& new Smarty;
SmartyPaginate::connect();
SmartyPaginate::setLimit(2);

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

SmartyPaginate::assign($smarty);
$smarty->display('index.tpl');

print print_r ($_data);
function get_db_results()
{

$url = 'localhost';
$identyfikator = '';
$haslo = '';
$baza_danych = 'test';

$serwer = @mysql_connect($url,$identyfikator,$haslo);
if (!$serwer)
{
exit ('Nie moze się połączyć z serwerem!');
}

if (!@mysql_select_db($baza_danych))
{
exit ('Nie może się połączyć z bazą danych');
}

$zapyt="SELECT * FROM test";
$news = @mysql_query($zapyt);
if(!$news)
{
echo "blad zapytania";
}

while ($array = mysql_fetch_array($news))
{
$_data[] = $_row;
}

$_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);
mysql_close($serwer);

return $_data;
}
?>

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

<br>
{section name=res loop=$results}
{$results[res]}
{/section}


<br>
{paginate_prev}
{paginate_middle}
{paginate_next}

Pierwszy raz tego używam i nie wiem za bardzo gdzie leży problem.
Będę wdzięczny za pomoc.

Pozdrawiam
Marcin
Back to top
View user's profile Send private message Visit poster's website
mafio69
Smarty n00b


Joined: 12 Oct 2008
Posts: 1

PostPosted: Mon Oct 13, 2008 4:56 pm    Post subject: Paginacja Reply with quote

Musisz poinformowac smarty że chcesz wyświetlić dane poprzez odwołanie się do zagnieżdzonych tablic np:
Code:

    {section name=res loop=$results}

  <table width="650" border="0" >
      <tr>
        <td height="39"><h1>{$results[res].nazwa}</h1></td>
        <td><img src="wozy/male/{$results[res].zdjecie}" alt="miniaturka" /> </td>
      </tr>
      <tr>
        <td colspan="2"><p>  {$results[res].kr_tresc} ... <a href="galeria.php?id={$results[res].id_galeria}&next={$paginate.current_item}">więcej</a></p>
        </td>
      </tr>
      <tr>
        <td>{$results[res].rok_powstania}</td>
        <td><div align="center">{$results[res].kraj}</div></td>
      </tr>
    </table>   
 
 {/section}   


Zwróc uwage na notację {$results[res].nazwa} ("nazwa" to nazwa pola w tabeli )
Back to top
View user's profile Send private message
ma_po
Smarty Rookie


Joined: 09 Jul 2008
Posts: 5

PostPosted: Thu Jul 30, 2009 8:52 am    Post subject: Reply with quote

Dzięki udało mi się wcześniej uporać się z tym. Teraz mam problem żeby zastosować w jednym projekcie kilka razy paginacje.

Nie wiem jak to ugryźć.

Pozdrawiam
Back to top
View user's profile Send private message Visit poster's website
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 -> Language: Polish 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