вопрос
Всем привет, подскажите пожалуйста как в модуле Музыкальная страничка приделать постраничную навигацию?
<?php
if (!defined('DATALIFEENGINE')) {
header("HTTP/1.0 403 Forbidden");
exit('Access denied');
}
$cat = (int) $_REQUEST['cat'];
$cat = $cat ? $cat : 1;
$queryMusic = $db->query("SELECT id,name,category,onserver,author,date FROM " . PREFIX . "_music ORDER BY date DESC"); /* LIMIT 50 */
while ($rowMusic = $db->get_row($queryMusic)) {
$tpl->load_template('music/musicmain.tpl');
$title = stripslashes($rowMusic['name']);
$tpl->set('{title}', $title);
$description = stripslashes($rowMusic['onserver']);
$tpl->set('{description}', $description);
if (date(Ymd, $rowMusic['date']) == date(Ymd, $_TIME)) {
$tpl->set('{date}', $lang['time_heute'] . langdate(", H:i", $rowMusic['date']));
}
elseif (date(Ymd, $rowMusic['date']) == date(Ymd, ($_TIME - 86400))) {
$tpl->set('{date}', $lang['time_gestern'] . langdate(", H:i", $rowMusic['date']));
}
else {
$tpl->set('{date}', langdate($config['timestamp_comment'], $rowMusic['date']));
}
if ($config['allow_alt_url'] == "yes") {
$go_page = $config['http_home_url'] . "user/" . urlencode($rowMusic['author']) . "/";
}
else {
$go_page = "$PHP_SELF?subaction=userinfo&user=" . urlencode($rowMusic['author']);
}
$username = stripslashes($rowMusic['author']);
$tpl->set('{username}', "<a onclick=\"showUserHint('" . urlencode($username) . "', this); return false;\" href=\"" . $go_page . "\">" . $username . "</a>");
$tpl->set('{id}', $rowMusic['id']);
$Category = $rowMusic['category'];
$Category = $db->super_query("SELECT * FROM " . PREFIX . "_music_category WHERE id=$Category");
$tpl->set('{category}', $Category['name']);
$tpl->set('{catid}', $Category['id']);
$tpl->set('{download}', $rowMusic['onserver']);
$tpl->compile('shablons');
}
$tpl->load_template('music/gmusicmain.tpl');
if ($config['allow_alt_url'] == "yes") {
$go_page = "" . $config['http_home_url'] . "music/add\"";
}
else {
$go_page = "" . $config['http_home_url'] . "index.php?do=music&op=add\"";
}
$tpl->set('{title}', "Музыка");
$tpl->set('{content}', $tpl->result['shablons']);
$tpl->set('{link}', $go_page);
$tpl->compile('MainMusic');
?>
//####################################################################################################################
// Навигация
//####################################################################################################################
if( $count_all ) {
$tpl->load_template( 'navigation.tpl' );
$no_prev = false;
$no_next = false;
if( isset( $cstart ) and $cstart != "" and $cstart > 0 ) {
$prev = $cstart / $perpage;
if( $config['allow_alt_url'] == "yes" ) {
if ($prev == 1)
$prev_page = $url_page . "/";
else
$prev_page = $url_page . "/page/" . $prev . "/";
$tpl->set_block( "'\[prev-link\](.*?)\[/prev-link\]'si", "<a href=\"" . $prev_page . "\">\\1</a>" );
}
else {
if ($prev == 1)
$prev_page = $PHP_SELF . "?" . $user_query;
else
$prev_page = $PHP_SELF . "?cstart=" . $prev . "&" . $user_query;
$tpl->set_block( "'\[prev-link\](.*?)\[/prev-link\]'si", "<a href=\"" . $prev_page . "\">\\1</a>" );
}
}
else {
$tpl->set_block( "'\[prev-link\](.*?)\[/prev-link\]'si", "<span>\\1</span>" );
$no_prev = TRUE;
}
if( $perpage ) {
$pages = "";
if( $count_all > $perpage ) {
$enpages_count = @ceil( $count_all / $perpage );
$cstart = ($cstart / $perpage) + 1;
if( $enpages_count <= 10 ) {
for($j = 1; $j <= $enpages_count; $j ++) {
if( $j != $cstart ) {
if( $config['allow_alt_url'] == "yes" ) {
if ($j == 1)
$pages .= "<a href=\"" . $url_page . "/\">$j</a> ";
else
$pages .= "<a href=\"" . $url_page . "/page/" . $j . "/\">$j</a> ";
}
else {
if ($j == 1)
$pages .= "<a href=\"$PHP_SELF?{$user_query}\">$j</a> ";
else
$pages .= "<a href=\"$PHP_SELF?cstart=$j&$user_query\">$j</a> ";
}
}
else
$pages .= "<span>$j</span> ";
}
}
else {
$start = 1;
$end = 10;
$nav_prefix = "<span class=\"nav_ext\">{$lang['nav_trennen']}</span> ";
if( $cstart > 0 ) {
if( $cstart > 6 ) {
$start = $cstart - 4;
$end = $start + 8;
if( $end >= $enpages_count ) {
$start = $enpages_count - 9;
$end = $enpages_count - 1;
$nav_prefix = "";
}
else
$nav_prefix = "<span class=\"nav_ext\">{$lang['nav_trennen']}</span> ";
}
}
if( $start >= 2 ) {
if( $config['allow_alt_url'] == "yes" ) $pages .= "<a href=\"" . $url_page . "/\">1</a> <span class=\"nav_ext\">{$lang['nav_trennen']}</span> ";
else $pages .= "<a href=\"$PHP_SELF?{$user_query}\">1</a> <span class=\"nav_ext\">{$lang['nav_trennen']}</span> ";
}
for($j = $start; $j <= $end; $j ++) {
if( $j != $cstart ) {
if( $config['allow_alt_url'] == "yes" ) {
if ($j == 1)
$pages .= "<a href=\"" . $url_page . "/\">$j</a> ";
else
$pages .= "<a href=\"" . $url_page . "/page/" . $j . "/\">$j</a> ";
}
else {
if ($j == 1)
$pages .= "<a href=\"$PHP_SELF?{$user_query}\">$j</a> ";
else
$pages .= "<a href=\"$PHP_SELF?cstart=$j&$user_query\">$j</a> ";
}
}
else $pages .= "<span>$j</span> ";
}
if( $cstart != $enpages_count ) {
if( $config['allow_alt_url'] == "yes" ) $pages .= $nav_prefix . "<a href=\"" . $url_page . "/page/{$enpages_count}/\">{$enpages_count}</a>";
else $pages .= $nav_prefix . "<a href=\"$PHP_SELF?cstart={$enpages_count}&$user_query\">{$enpages_count}</a>";
}
else $pages .= "<span>{$enpages_count}</span> ";
}
}
$tpl->set( '{pages}', $pages );
}
if( $perpage and $perpage < $count_all and $i < $count_all ) {
$next_page = $i / $perpage + 1;
if( $config['allow_alt_url'] == "yes" ) {
$next = $url_page . '/page/' . $next_page . '/';
$tpl->set_block( "'\[next-link\](.*?)\[/next-link\]'si", "<a href=\"" . $next . "\">\\1</a>" );
} else {
$next = $PHP_SELF . "?cstart=" . $next_page . "&" . $user_query;
$tpl->set_block( "'\[next-link\](.*?)\[/next-link\]'si", "<a href=\"" . $next . "\">\\1</a>" );
};
}
else {
$tpl->set_block( "'\[next-link\](.*?)\[/next-link\]'si", "<span>\\1</span>" );
$no_next = TRUE;
}
if( ! $no_prev or ! $no_next ) {
$tpl->compile( 'navi' );
switch ( $config['news_navigation'] ) {
case "2" :
$tpl->result['content'] = $tpl->result['navi'].$tpl->result['content'];
break;
case "3" :
$tpl->result['content'] = $tpl->result['navi'].$tpl->result['content'].$tpl->result['navi'];
break;
default :
$tpl->result['content'] .= $tpl->result['navi'];
break;
}
}
$tpl->clear();
}