|
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 |
Simply Seth Smarty Rookie
Joined: 27 Jan 2005 Posts: 8
|
Posted: Thu Jan 27, 2005 8:08 am Post subject: Smarty Paginate Invalid Tags |
|
|
I've spent days trying to figure this pagination stuff out.
I've read the example many times and I've come close to getting it to work.
I get this error when attempting to run my php script :
Quote: | Fatal error: Smarty error: [in /var/www/templates/index.tpl line 55]: syntax error: unrecognized tag 'paginate_prev' (Smarty_Compiler.class.php, line 565) in /usr/share/Smarty/libs/Smarty.class.php on line 1088 |
it seems to have an issue with these three tags in my index.tpl file :
Code: | {paginate_prev} {paginate_middle} {paginate_next} |
The above three tags I put as is in the index.tpl file .. I don't know if I'm supposed to wrap them in some other tag or something
IT works fine without the three tags (except for pagination of course)
here is my index.php file:
Code: | <?php
session_start();
header("Cache-control: private"); //IE 6 Fix
require ('Smarty.class.php');
require('/usr/share/Smarty/libs/SmartyPaginate.class.php');
$smarty =& new Smarty;
// required connect
SmartyPaginate::connect();
// set items per page
SmartyPaginate::setLimit(7);
$smarty->plugin_dir = '/var/www/plugins/';
$smarty->template_dir = '/var/wwww/templates/';
$smarty->compile_dir = '/var/www/templates_c/';
$smarty->config_dir = '/var/www/configs/';
$smarty->cache_dir = '/var/www/cache/';
require 'inc/whitepages.inc';
$smarty->assign('results',$action);
$smarty->assign('rnb',rawurlencode('r&b'));
SmartyPaginate::assign($smarty);
$smarty->display('/var/www/templates/index.tpl');
?>
|
here is my whitepages.inc file :
Code: |
<?php
/*
ini_set('display_errors','off');
ini_set('log_errors','1');
ini_set('error_log','./errors.txt');
ini_set('error_reporting','5');
ini_set('ignore_repeated_errors','1');
*/
if (empty($_POST['keyword']))
{
if (empty($_GET['type']))
{
$type = "artists";
$_SESSION['type'] = "artists";
$smarty->assign('sess_type',$_SESSION['type']);
}
else
{
$type = addslashes(strtolower(trim($_GET['type'])));
$_SESSION['type'] = addslashes(strtolower(trim($_GET['type'])));
$smarty->assign('sess_type',$_SESSION['type']);
}
if (empty($_GET['genre']))
{
$genre = 0;
}
else
{
$genre = addslashes(strtolower(trim($_GET['genre'])));
}
$list_artists = new whitepages;
$action = $list_artists -> list_of_artists($genre,$type);
$smarty->assign('list_array',$action);
}
else
{
$keyword = addslashes(strtolower(trim($_POST['keyword'])));
$search_artists = new whitepages;
$action = $search_artists->search_artists($keyword);
$smarty->assign('list_array',$action);
}
//WhitePages Class
class whitepages
{
//Search Function
//This is the List function
function list_of_artists($genre,$type)
{
//If $genre is empty ...
if (empty($genre))
{
// ... And if $type is artists ...
if ($type == "artists")
{
//... We use this SQL command
//Which searches for ARTISTS
$list_sql =<<< SQL
select artists_name, artists_label,artists_url,artists_genre,artists_type
from artists where (artists_type='artist' or artists_type='both')
AND artists_active='y'
order by artists_name ASC
SQL;
$list_sql .= ' LIMIT '.SmartyPaginate::getCurrentIndex().','.SmartyPaginate::getLimit();
}
//OR if $genre is empty and $type is producers ...
elseif ($type == "producers")
{
// ... We use this SQL command
//Which searches for PRODUCERS
$list_sql =<<< SQL
select artists_name, artists_label,artists_url,artists_genre,artists_type
from artists where (artists_type='producer' or artists_type='both')
AND artists_active='y'
order by artists_name ASC
SQL;
$list_sql .= ' LIMIT '.SmartyPaginate::getCurrentIndex().','.SmartyPaginate::getLimit();
}//end of type check
} //end of genre check 1
//If the genre is rap or r&b
elseif($genre == "rap" || $genre == "r&b")
{
//if $type is artists
if ($type == "artists")
{
//We use this SQL command
//Which searches for ARTISTS according to chosen GENRE
$list_sql =<<< SQL
select artists_name, artists_label,artists_url,artists_genre,artists_type
from artists where artists_genre LIKE '%$genre%'
AND (artists_type='artist' or artists_type='both')
AND artists_active='y'
order by artists_name ASC
SQL;
$list_sql .= ' LIMIT '.SmartyPaginate::getCurrentIndex().','.SmartyPaginate::getLimit();
} //end of type check
//If genre is rap or r&b and type is producers
elseif ($type == "producers")
{
//We use this SQL command
//Which searches for PRODUCERS according to chosen GENRE
$list_sql =<<< SQL
select artists_name, artists_label,artists_url,artists_genre,artists_type
from artists where artists_genre LIKE '%$genre%'
AND (artists_type='producer' or artists_type='both')
AND artists_active='y'
order by artists_name ASC
SQL;
$list_sql .= ' LIMIT '.SmartyPaginate::getCurrentIndex().','.SmartyPaginate::getLimit();
}//end of type check
}//end of genre check 2
//If genre is not Rap or R&B
elseif ($genre == "other")
{
//If $type is artists
if ($type == "artists")
{
//We use this SQL command
//Which searches for ARTISTS according to
//House,Spoken Word and Techno GENRES
$list_sql =<<< SQL
select artists_name, artists_label,artists_url,artists_genre,artists_type
from artists where
(artists_genre LIKE '%house%' OR artists_genre LIKE '%spoken word%'
OR artists_genre LIKE '%techno%')
AND (artists_type='artist' OR artists_type='both')
AND artists_active='y'
order by artists_name ASC
LIMIT SmartyPaginate::getCurrentIndex(),SmartyPaginate::getLimit()
SQL;
$list_sql .= ' LIMIT '.SmartyPaginate::getCurrentIndex().','.SmartyPaginate::getLimit();
} //end of type check
//IF genre is not Rap or R&B and type is producers
elseif ($type == "producers")
{
//We use this SQL command
//Which searches for PRODUCERS according to
//House,Spoken Word and Techno GENRES
$list_sql =<<< SQL
select artists_name, artists_label,artists_url,artists_genre,artists_type
from artists where
(artists_genre LIKE '%house%' OR artists_genre LIKE '%spoken word%'
OR artists_genre LIKE '%techno%')
AND (artists_type='producer' OR artists_type='both')
AND artists_active='y'
order by artists_name ASC
SQL;
$list_sql .= ' LIMIT '.SmartyPaginate::getCurrentIndex().','.SmartyPaginate::getLimit();
} //end of type check
} //end of genre check 3
$list_link = mysql_connect("localhost", "nunya", "beezwax");
if (!isset($list_link))
{
fwrite($err_file,mysql_error());
fwrite($err_file,"\n");
}
else
{ //we select the DataBase
$list_select = mysql_select_db("artists");
if (!$list_select)
{
fwrite($err_file,mysql_error());
fwrite($err_file,"\n");
}
else
{
//we run the actual query
$list_query = mysql_query($list_sql,$list_link);
echo $list_sql;
//we count the results for pagination
$_SESSION['count'] = mysql_num_rows($list_query);
SmartyPaginate::setTotal(count($list_query));
while ($list_data = mysql_fetch_assoc($list_query))
{
$list_artists_array[] = $list_data;
}
return $list_artists_array;
}
}
mysql_close($list_link);
} //end of list function
} //end of whitepages class
?>
|
|
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Jan 27, 2005 2:34 pm Post subject: |
|
|
You have to put the three pagination functions in your plugin directory. |
|
Back to top |
|
Simply Seth Smarty Rookie
Joined: 27 Jan 2005 Posts: 8
|
Posted: Thu Jan 27, 2005 3:24 pm Post subject: |
|
|
They are in fact there :
Quote: | ls /var/www/plugins
function.paginate_middle.php function.paginate_prev.php
function.paginate_next.php function.pagination.php
|
|
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Thu Jan 27, 2005 3:55 pm Post subject: |
|
|
safe_mode enabled?
can you use other plugins from /var/www/plugins? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu Jan 27, 2005 5:23 pm Post subject: |
|
|
Subtle error -- in the line:
$smarty->plugin_dir = '/var/www/plugins/';
it ought be plugins_dir. |
|
Back to top |
|
Simply Seth Smarty Rookie
Joined: 27 Jan 2005 Posts: 8
|
Posted: Thu Jan 27, 2005 5:54 pm Post subject: |
|
|
kewl ... all works except if I put
Code: | {paginate_middle format="page"} |
but if I leave off the quotes it works ... go figger
Thanks for all the help so far |
|
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
|
|