- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
$url_view = 'pages/news';// страница вида
$data = array(); //Создаем массив дата
// сегменты урл
$data['segment_1'] = $filter_1;
$data['segment_2'] = $filter_2;
$limit = 10; // вывод новостей
$num_links = 4; // кол-во страниц во круг текущей
$uri_segment = 5; // сегмент ссылки
$offset = ($page - 1) * $limit; // переводим page в offset
if(!is_numeric($filter_2)) {$filter_2 = iconv('utf-8', 'windows-1251', urldecode($filter_2));}
$base_url = '/page/filter/'.$filter_1.'/'.$filter_2.'/';
// разбираем 1 фильтр для проверки
$filter_global = explode("_",$filter_1);
if($filter_global[0] == 'user') {$filter_1 = 'user'; $user_id = (int)$filter_global[1];}
// описание каждого элемента фильтра
switch($filter_1) {
case 'date':
$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
break;
case 'date_day':
$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
break;
case 'date_month':
$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
break;
case 'date_year':
$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
break;
case 'rating':
$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
break;
case 'random':
$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
break;
case 'moderation':
$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
break;
case 'user':
$filter_1 = $filter_global[0].'_'.$filter_global[1]; // собираем обратно
$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
break;
default:
$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
break;
}
$this->auxiliary->pagination($base_url,$uri_segment,$num_links,$total,$limit);//настройки пагинации
$this->auxiliary->general_view($data,'title_best','description_best','keywords_best',$url_view); // общий вид
проверьте на наличие гавно кода .
Контроллер фильтра выдачи в Codeigniter