만들면서 배우는 CodeIgniter Q&A

제목 페이징 부분 학습 중입니다.
글쓴이 황현빈 작성시각 2020/11/16 09:46:46
댓글 : 3 추천 : 0 스크랩 : 0 조회수 : 6902   RSS

페이징 부분 학습 중인데 페이징 번호를 클릭하면 왜 base_url 이 현재 url 뒤어 붙는건가요?

 

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

  // 게시판 메인 컨트롤러

  class Board extends CI_Controller{

    function __construct(){

      parent::__construct();        $this->load->database();        $this->load->model('board_m');        $this->load->helper(array('url', 'date'));    }

    // 주소에 메서드가 생략되었을 때 실행되는 기본 메서드가    public function index(){      $this->lists();    }

    // 사이트 헤더, 푸터가 자동으로 추가    public function _remap($method){      // 헤더 include      $this->load->view('header_v');

      if( method_exists($this, $method) ){        $this->{"{$method}"}();      }

      //푸터 include      $this->load->view('footer_v');    }

    //목록 불러오기    public function lists(){

      // 페이지네이션 라이브러리 로딩 추가      $this->load->library('pagination');

      // 페이지네이션 설정      $config['base_url'] = 'bbs/index.php/board/lists/ci_board/page'; // 페이징 주소      $config['total_rows'] = $this->board_m->get_list($this->uri->segment(3), 'count');

      // 게시물의 전체 개수      $config['per_page'] = 5; // 한 페이지에 표시할 게시물 수      $config['uri_segment'] = 5; // 페이지 번호가 위치한 세그먼트

      // 페이지네이션 초기화      $this->pagination->initialize($config);      // 페이징 링크를 생성하여 view에 사용할 변수에 할당      $data['pagination'] = $this->pagination->create_links();

      // 게시물 목록을 불러오기 위한 offset, limit 값 가져오기      $page = $this->uri->segment(6, 1);

      if ( $page > 1 ) {        $start = (($page/$config['per_page'])) * $config['per_page'];      } else {        $start = ($page-1) * $config['per_page'];      }

      $limit = $config['per_page'];

      $data['list'] = $this->board_m->get_list($this->uri->segment(3), '', $start, $limit);

      $this->load->view('board/list_v', $data);    }

  }

 ?>

첨부파일 20201116_094400.png (4.2 KB)
20201116_094413.png (6.0 KB)
20201116_094616.png (125.9 KB)
 다음글 ci 처음 시작했는데 시작부터 막히네요. 도움좀 부탁드... (4)
 이전글 페이징 쪽 하고 있는데요. (1)

댓글

황현빈 / 2020/11/16 09:59:45 / 추천 0

$config['base_url'] = base_url().'index.php/board/lists/ci_board/page'; 이렇게 바꿔서 해결했는데

base_url()을 정의 하는 곳은 어디인가요ㅠㅠ

PureAni / 2020/11/16 10:14:19 / 추천 0
변종원(웅파) / 2020/11/16 10:35:21 / 추천 0