 |
Smarty
The discussions here are for Smarty, a template engine for the PHP programming language. Dedicated server web hosting provided by Guru-host.eu. |
| View previous topic :: View next topic |
| Author |
Message |
juls Smarty n00b
Joined: 01 Jun 2005 Posts: 2
|
Posted: Wed Jun 01, 2005 8:13 pm Post subject: SmartyPaginate prev and next links problem |
|
|
Everything seems to work except the display of the previous and next links...
When I add these commands to my template I get an error message:
{paginate_prev} {paginate_middle} {paginate_next}
Error: Fatal error: Smarty error: [in test1.tpl line 21]: syntax error: unrecognized tag 'paginate_prev' (Smarty_Compiler.class.php, line 580) in...
Here is my php file:
[php:1:2ad9e19f88]
session_start();
require 'SmartyPaginate\libs\SmartyPaginate.class.php';
require('Smarty.class.php');
$smarty = new Smarty();
$smarty->template_dir = 'templates/';
$smarty->compile_dir = 'templates_c/';
$smarty->cache_dir = 'cache/';
// required connect
SmartyPaginate::connect();
// set items per page
SmartyPaginate::setLimit(25);
// assign your db results to the template
$smarty->assign('results', get_db_results());
// assign {$paginate} var
SmartyPaginate::assign($smarty);
$smarty->display('test1.tpl');
function get_db_results() {
$_link = mysql_connect('localhost', '', '');
mysql_select_db('db');
$_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM eval_courses 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()";
$_result = mysql_query($_query);
$_row = mysql_fetch_array($_result, MYSQL_ASSOC);
print 'NUM: ' . $_row["FOUND_ROWS()"];
SmartyPaginate::setTotal($_row['FOUND_ROWS()']);
mysql_free_result($_result);
mysql_close($_link);
return $_data;
}[/php:1:2ad9e19f88]
And my template:
| Code: | <html>
<head>
<title>Smarty</title>
</head>
<body>
<br>
<br>
{* display pagination header *}
Items {$paginate.first}-{$paginate.last} out of {$paginate.total} displayed.
<br>
{* display results *}
{section name=res loop=$results}
{$results[res].course} <br>
{/section}
{* display pagination info *}
{paginate_prev} {paginate_middle} {paginate_next}
</body>
</html>
|
I would really appreciate some help... I've been dealing with this for a few hrs now.
Thanks
Juls |
|
| Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7036 Location: Lincoln Nebraska, USA
|
Posted: Wed Jun 01, 2005 9:50 pm Post subject: |
|
|
| Quote: | | unrecognized tag 'paginate_prev' |
Do you have the function.paginate_prev.php file in the plugin directory? |
|
| Back to top |
|
juls Smarty n00b
Joined: 01 Jun 2005 Posts: 2
|
Posted: Wed Jun 01, 2005 10:14 pm Post subject: |
|
|
mohrt, I'm pretty embarrassed right now I did not read through the installation instructions and see that I had to copy these files to the plugin directory! Shame on me... Thank you for pointing this out.
I'm (obviously) new to Smarty and related software. But, I'm really enjoying it! Ok, now that I have the pagination part working, I now have to see whether I can make it work with Mojavi...
Thanks again. |
|
| 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
|