질문 Q #9754
[초보]후크
헛발이 2012-02-24 12:50:39
Hooks에서요..

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

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

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


답변 7
#1 변종원(웅파) 2012-02-24 13:58:16
$this->ci->load->_ci_view_path;  이게 이해가 안되네요.

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


#2 한대승(불의회상) 2012-02-24 14:09:49
ㅎㅎ

$this
->ci->_ci_view_path;

의 오타 인듯.. ^^

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

$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();
    }
  }

}

#4 변종원(웅파) 2012-02-24 15:58:49
잘못 쓴거 같네요.

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