CI 묻고 답하기

제목 [초보]후크
글쓴이 헛발이 작성시각 2012/02/24 12:50:39
댓글 : 7 추천 : 0 스크랩 : 0 조회수 : 16561   RSS
Hooks에서요..

$this->ci =& get_instance();
echo $this->ci->load->_ci_view_path;
이렇게 하면 자꾸 에라가 나는데요.. 사용못하나요?

에라가 이렇게 나는데요..

Severity: Notice
Message: Undefined property: Test::$_ci_view_path


 다음글 컨트롤러 메소드 안에 db를 select 후 updat... (5)
 이전글 ? 가 생깁니다 (2)

댓글

변종원(웅파) / 2012/02/24 13:58:16 / 추천 0
$this->ci->load->_ci_view_path;  이게 이해가 안되네요.

파일도 아니고 모델, 뷰도 아니고 ci 로드 규칙에 없는건데요?


한대승(불의회상) / 2012/02/24 14:09:49 / 추천 0
ㅎㅎ

$this
->ci->_ci_view_path;

의 오타 인듯.. ^^

헛발이 / 2012/02/24 14:10:08 / 추천 0
인터넷에 나와 있는 예제를 보고 하는 중인데 에라가 나서요~

$hook['post_controller_constructor'][] = array(
                                'class'    => 'Mobile',
                                'function' => 'view_set',
                                'filename' => 'Mobile.php',
                                'filepath' => 'hooks'
                                );

$hook['display_override'][] = array(
                                'class'    => 'Mobile',
                                'function' => 'display',
                                'filename' => 'Mobile.php',
                                'filepath' => 'hooks'
                                );

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

class Mobile {

 function Mobile()
 {
    $this->ci =& get_instance();
    $this->ci->load->library('user_agent');
 }

  function view_set()
  {
    if ($this->ci->agent->is_mobile())
    {
      $this->ci->load->_ci_view_path .= 'mobile/';
    }
  }

  function display()
  {
    if ($this->ci->agent->is_mobile())
    {
      $buffer = $this->ci->output->get_output();

      $buffer = preg_replace("/\n/", '', $buffer);
      $buffer = mb_convert_kana($buffer, 'aks', "UTF-8");
      $buffer = mb_convert_encoding($buffer, 'SJIS', $this->ci->config->item('charset'));

      header("Content-type: text/html; charset=Shift_JIS;");
      echo $buffer;
    }
    else
    {
      echo $this->ci->output->get_output();
    }
  }

}

변종원(웅파) / 2012/02/24 15:58:49 / 추천 0
잘못 쓴거 같네요.

$this->ci->_ci_view_path 가 맞는거 같은데요
헛발이 / 2012/02/24 16:54:42 / 추천 0
음... 잘 안되는군요.. ^^;
헛발이 / 2012/02/25 11:57:41 / 추천 0
찾아보니 제가 HMVC를 사용중이여서 그런거군요..
HMVC를 사용중일땐 궁합이 잘 안맞나 봅니다..
ㅠㅠ
헛발이 / 2012/02/25 12:28:28 / 추천 0
결국 app/third_party/MX/Loader.php를 조금 수정했네요...
수정한것 때문에 별탈이 없음 좋겠네요... ㅋ
(초보자의 심정... )