Вы не зашли.
Страницы 1
/engine/includes/comments.show.php
#1. Найти
if ($config['use_avatars']) {
$sql = "select c.*, u.avatar from ".prefix."_comments c left join ".uprefix."_users u on c.author_id = u.id where c.post=".db_squote($newsID).($commID?(" and c.id=".db_squote($commID)):'')." order by c.id".($config['reverse_comments']?' desc':'');
} else {
$sql = "select c.* from ".prefix."_comments c WHERE c.post=".db_squote($newsID).($comment_id?(" and c.id=".db_squote($comment_id)):'')." order by c.id".($config['reverse_comments']?' desc':'');
}
#1. Заменить на
$showNumber = 30; // количество комментариев на страницу
$cstart = intval($_REQUEST['page']) ? abs(intval($_REQUEST['page'])) : 1;
$limit_start = ($cstart - 1) * $showNumber;
$limit_count = $showNumber;
if ($config['use_avatars']) {
$sql = "select c.*, u.avatar from ".prefix."_comments c left join ".uprefix."_users u on c.author_id = u.id where c.post=".db_squote($newsID).($commID?(" and c.id=".db_squote($commID)):'')." order by c.id".($config['reverse_comments']?' desc':'').($commID?'':" limit ".$limit_start.",".$limit_count);
} else {
$sql = "select c.* from ".prefix."_comments c left join ".uprefix."_users u on c.author_id = u.id WHERE c.post=".db_squote($newsID).($commID?(" and c.id=".db_squote($commID)):'')." order by c.id".($config['reverse_comments']?' desc':'').($commID?'':" limit ".$limit_start.",".$limit_count);
}
#2. Найти
...
exec_acts('comments', $row);
$tpl -> vars($templateName, $tvars);
if ($commID) { echo $tpl -> show($templateName); }
$template['vars']['mainblock'] .= $tpl -> show($templateName);
}
#2. Добавить после
$maxNavigations = 10; // количество отображаемых страниц; соответствует указанному лишь приблизительно
// Make navigation bar
$navigations = getNavigations(tpl_dir.$config['theme']);
$tpl -> template('pages', tpl_dir.$config['theme']);
$which_link = 'full_page';
if ($config['category_link']) {
global $catz;
$row['catid'] = array();
$categories = explode('-', category);
foreach ($categories as $cat)
{
$row['catid'][] = $catz[$cat]['id'];
}
$row['catid'] = implode(',', $row['catid']);
} else {
$row['postdate'] = mktime(0, 0, 0, month, day, year);
}
$row['alt_name'] = altname;
// Prev page link
if ($limit_start && $comnum) {
$prev = floor($limit_start / $showNumber);
$row['page'] = $prev;
$tvars['regx']["'\[prev-link\](.*?)\[/prev-link\]'si"] = str_replace('%page%',"$1",str_replace('%link%',GetLink($which_link, $row), $navigations['prevlink']));
} else {
$tvars['regx']["'\[prev-link\](.*?)\[/prev-link\]'si"] = "";
$no_prev = true;
}
$commCount = $mysql->result("SELECT count(*) as count FROM ".prefix."_comments WHERE post=".db_squote($newsID).($commID?(" and id=".db_squote($commID)):''));
$pages_count = ceil($commCount / $showNumber);
$pages = '';
$sectionSize = floor($maxNavigations / 3);
if ($pages_count > $maxNavigations) {
// We have more than 10 pages. Let's generate 3 parts
// Situation #1: 1,2,3,4,[5],6 ... 128
if ($cstart < ($sectionSize * 2)) {
$pages .= generateNavigations($cstart, 1, $sectionSize * 2, $which_link, $row, $navigations);
$pages .= $navigations['dots'];
$pages .= generateNavigations($cstart, $pages_count-$sectionSize, $pages_count, $which_link, $row, $navigations);
} elseif ($cstart > ($pages_count - $sectionSize * 2 + 1)) {
$pages .= generateNavigations($cstart, 1, $sectionSize, $which_link, $row, $navigations);
$pages .= $navigations['dots'];
$pages .= generateNavigations($cstart, $pages_count-$sectionSize*2 + 1, $pages_count, $which_link, $row, $navigations);
} else {
$pages .= generateNavigations($cstart, 1, $sectionSize, $which_link, $row, $navigations);
$pages .= $navigations['dots'];
$pages .= generateNavigations($cstart, $cstart-1, $cstart+1, $which_link, $row, $navigations);
$pages .= $navigations['dots'];
$pages .= generateNavigations($cstart, $pages_count-$sectionSize, $pages_count, $which_link, $row, $navigations);
}
} else {
// If we have less then 10 pages
$pages .= generateNavigations($cstart, 1, $pages_count, $which_link, $row, $navigations);
}
$tvars['vars']['pages'] = $pages;
// Next page link
if (($prev + 2 <= $pages_count) && $comnum) {
$row['page'] = $prev + 2;
$tvars['regx']["'\[next-link\](.*?)\[/next-link\]'si"] = str_replace('%page%',"$1",str_replace('%link%',GetLink($which_link, $row), $navigations['nextlink']));"<a href=\"".GetLink($which_link, $row)."\">$1</a>";
} else {
$tvars['regx']["'\[next-link\](.*?)\[/next-link\]'si"] = "";
$no_next = true;
}
if ($comnum && ($pages_count>1)){
$tpl -> vars('pages', $tvars);
$template['vars']['mainblock'] .= $tpl -> show('pages');
}
Изменено insider (2009-07-08 02:28:08)
Не в сети
Страницы 1