CI 코드

제목 ci 452 modified Pagination
글쓴이 darkninja 작성시각 2024/07/14 17:03:45
댓글 : 0 추천 : 0 스크랩 : 0 조회수 : 555   RSS

ci4의 system/pager를 수정해서 링크들을 모두 보일수 있게 하였습니다.

검증을 더 해보아야 하는데 메모리부족으로 lock상태입니다 ...

시스템 코어를 수정해도 되고

아니면 app/libraries에 두고 컨트롤러에서 use로 불러와야 수정된 pager가 사용됩니다.

추가된 설정을 어디에서 할것인지가 문제인데

PagerRenderer의 setSurroundCount가 호출되기 전에 해야 합니다

첨부파일은 실행 가능한 완전한 형태가 아니고

수정하여 사용해야 합니다.

오류발생시 지적해 주시면 감사하겠습니다.

<?php namespace App\Controllers;

//use App\Libraries\MY_Pagination;

use Config\Services as AppServices;
use Config\Pager as PagerConfig;
use App\Libraries\Pager\Pager;

class Board extends BaseController {

    public function index($board_table=BOARD, $view_mode='simple', $page_index=1, $order='group asc, order asc') 
    {
		if ($view_mode=='simple')
			$per_page = $this->per_page;
		else
			$per_page = $this->per_page_list;

    	$total_rows = 0;
    	$boards = $this->board_model->paginated($board_table, $page_index, $per_page, $total_rows, $order);
        $redirect_url = $this->board_controller.'/index/'.$board_table.'/'.$view_mode;

        $base_url = $redirect_url;
    	$uri_segment = 5;
    	$group = 'default';
		$template = 'default_full';

        $config = config(PagerConfig::class);
        $view = AppServices::renderer(null, null, false);
        $MyPager = new Pager($config, $view);

    	$MyPager->setPath($base_url, $group); // Additionally you could define path for every group.
		/*
		$MyPager->resetDetails([
            'showFirst'     => true,
            'showPrevious'  => true,
            'showPreviousPage' => true,
            'showNextPage'  => true,
            'showNext'      => true,
            'showLast'      => true,
            'surroundCount_previous' => 5,
            'surroundCount_next' => 5,
		], $group);
		*/

		$pageLinks = $MyPager->makeLinks($page_index, $per_page, $total_rows, $template, $uri_segment, $group);

/*
        $base_url = ROOT_PATH.'/'.$redirect_url;
        $MyPager = new MY_Pagination();
		$page_config = array();
		$page_config['base_url'] = $base_url;
		$page_config['per_page'] = $per_page;
		$page_config['total_rows'] = $total_rows;
		$page_config['uri_segment'] = 5;
		$MyPager->initialize($page_config);
        $pageLinks = $MyPager->create_links();
*/

    	$t = intval(($total_rows-1) / $per_page) + 1;
    	if ($page_index > $t) {
      	    $this->response->redirect(site_url($redirect_url.'/'.$t));
	    }

    	$data = Array(
      		'head_data' => Array(
        		'title' => 'Board list',
      		),
    	  	'view_data' => Array(
	        	'boards' => $boards,
		        'pageLinks' => $pageLinks,

				'cut_subject' => $this->cut_subject,
    		    'cut_contents' => $this->cut_contents,
    		    'page_index' => $page_index,
		        'db' => $this->db,
    		    'board_table' => $board_table,
        		'board_model' => $this->board_model,
				'view_mode' => $view_mode,
      		),
	    );

    	$this->render_page('index', $data);
  	}


}

 

첨부파일 pager.zip (15.9 KB)
 이전글 MY_Pagination 과거로의 회귀...

댓글

없음