on
CodeIgniter Pagination Reverse Patch
CodeIgniter Pagination Reverse Patch
처음 페이지가 1이 아닌, 맨 끝 페이지부터 시작할 때 패치
페이지네이션 설정은 이렇게
$pagination_config = array( 'base_url' => '/' . $code . '/' . $id, 'total_rows' => $comment_total_rows, 'per_page' => 5, 'uri_segment' => 3, 'num_links' => 5, 'use_page_numbers' => true, 'suffix' => '?' . http_build_query($_GET, '', '&'), /* reverse 모드일 경우 아래 세 파라미터 추가 */ 'current_page' => $page, 'default_page' => $this->comment_m->getLastPage($code, $id), 'is_reverse' => true ); $pagination_config['first_url'] = $pagination_config['base_url'] . '?' . http_build_query($_GET);
libraries/Pagination.php의 부분을 이렇게 바꿔준다
// var $anchor_class = ... 밑에 추가 (2.2.0 기준 Line 61) var $default_page = 0; var $current_page = 0; var $is_reverse = false; // Set current page to 1 if using page numbers instead of offset 주석 위에 추가 (2.2.0 기준 Line 166) if ($this->is_reverse && $this->current_page > 0) { $this->cur_page = $this->current_page; $base_page = $this->default_page; } // Render the pages 부분의 if ($i >= $base_page) 부분을 아래와 같이 변경 (2.2.0 기준 Line 273) if ($this->is_reverse == true) { if ($this->cur_page == $loop) { $output .= $this->cur_tag_open.$loop.$this->cur_tag_close; // Current page } else if ($loop > 0) { $n = ($i == $base_page) ? '' : $i; if ($n == '' && $this->first_url != '') { $output .= $this->num_tag_open.'anchor_class.'href="'.$this->first_url.'">'.$loop.''.$this->num_tag_close; } else { $n = ($n == '') ? '' : $this->prefix.$n.$this->suffix; $output .= $this->num_tag_open.'anchor_class.'href="'.$this->base_url.$n.'">'.$loop.''.$this->num_tag_close; } } } else { if ($i >= $base_page) { if ($this->cur_page == $loop) { $output .= $this->cur_tag_open.$loop.$this->cur_tag_close; // Current page } else { $n = ($i == $base_page) ? '' : $i; if ($n == '' && $this->first_url != '') { $output .= $this->num_tag_open.'anchor_class.'href="'.$this->first_url.'">'.$loop.''.$this->num_tag_close; } else { $n = ($n == '') ? '' : $this->prefix.$n.$this->suffix; $output .= $this->num_tag_open.'anchor_class.'href="'.$this->base_url.$n.'">'.$loop.''.$this->num_tag_close; } } } }
그냥 돌아가는지만 보고 내놓은 거니 오류 있을 수 있음 & 소스 더러움 -_-;;
뭔가 나중에 꼬였으면 다시 수정해서 글 업데이트 할 예정
from http://ejnahc.tistory.com/505 by ccl(A) rewrite - 2021-10-28 03:26:39