не могу сделать навигацию по такому шаблону <<< 1,2,3,
4,5,6 >>>
private function get_navigation_menu($app)
{
$app->set("menu", $app->get('DB')->exec("SELECT * FROM `categories`"));
$app->set("static_page", $app->get('DB')->exec("SELECT * FROM `static_page`"));
}
public function pagination($table='posts')
{
$current_page = $this->app->get('PARAMS.page')-1;
#переменная news - находится в конфиге -_- news = количество новостей на страницу.
$next_page = (1+$current_page) * $this->app->get("news");
$prev_page = ($current_page-1) * $this->app->get("news");
if($table == 'posts')
{
$category_id = $this->app->get('PARAMS.id_category');
if($this->app->get("admin_panel"))
{
$query = "SELECT `id` FROM `posts` ORDER BY `id` desc LIMIT ?,?";
$query_params['inc'] = array(
1 => $next_page,
2 => $this->app->get('news')
);
$query_params['dec'] = array(
1 => $prev_page,
2 => $this->app->get('news')
);
}
else
{
$query = "SELECT `id` FROM `posts` WHERE `category_id` = ? ORDER BY `id` desc LIMIT ?,?";
#Только для удобочитаемости, я не про форматирование текста =_=
$query_params['inc'] = array(
1 => $this->app->get('PARAMS.id_category'),
2 => $next_page,
3 => $this->app->get('news')
);
$query_params['dec'] = array(
1 => $this->app->get('PARAMS.id_category'),
2 => $prev_page,
3 => $this->app->get('news')
);
}
}
else
{
$category_id = $table;
$query = "SELECT `id` FROM $table ORDER BY `id` desc LIMIT ?,?";
$query_params['inc'] = array(
1 => $next_page,
2 => $this->app->get('news')
);
$query_params['dec'] = array(
1 => $prev_page,
2 => $this->app->get('news')
);
}
Изменил: YouMobe (11.04.2014 / 08:42)