강좌게시판
| 웅파 | |
|---|---|
|
1.7.3 기준으로 작성되었습니다. 컨트롤러와 모델을 같이 쓰면서 웹브라우저로 접속했는지 모바일브라우저로 접속했는지에 따라 웹UI와 모바일UI를 보여주도록 구성한 것입니다. 1. application/config/config.php 수정 : 기본값은 FALSE 입니다. /* |-------------------------------------------------------------------------- | Enable/Disable System Hooks |-------------------------------------------------------------------------- | | If you would like to use the "hooks" feature you must enable it by | setting this variable to TRUE (boolean). See the user guide for details. | */ $config['enable_hooks'] = TRUE;2. application/config/hooks.php 입력
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| Hooks
| -------------------------------------------------------------------------
| This file lets you define "hooks" to extend CI without hacking the core
| files. Please see the user guide for info:
|
| http://codeigniter.com/user_guide/general/hooks.html
|
*/
$hook['post_controller_constructor'][] = array(
'function' => 'b_check',
'filename' => 'browser_check.php',
'filepath' => 'hooks'
);
/* End of file hooks.php */
/* Location: ./system/application/config/hooks.php */
3. application/hooks 디렉토리(위 선언파일에서 filepath 명시한대로)에 browser_check.php 라는 파일을 만듭니다.
<?php
//browser_check.php
function b_check() {
if ( preg_match('/(iPhone|Android|iPod|iPad|BlackBerry|IEMobile|HTC|Server_KO_SKT|SonyEricssonX1|SKT)/',$_SERVER['HTTP_USER_AGENT']) )
{
define('BROWSER_TYPE', 'M');
}
else
{
define('BROWSER_TYPE', 'W');
}
}
?>
function 명은 hooks.php 파일에서 명시한대로 b_check 로 합니다.이제 BROWSER_TYPE 이라는 상수의 값에 따라 컨트롤러에서 view를 제어해줍니다. 1편 끝..... 퍼가실 때는 출처 명기 바랍니다. |
|
| 번호 | 제 목 | 글쓴이 | 날짜 | 조회 | 추천수 |
|---|---|---|---|---|---|
| 247 | CodeIgniter 보안강화 [10] | tpae | 2012-01-16 | 2169 | 2 |
| 231 | 개별 개발환경 셋팅하기 [4] | 웅파 | 2011-12-02 | 2922 | 0 |
| 223 | [슬라이드] 쌩초보를 위한 발표자료 [11] | 인스카 | 2011-11-14 | 1748 | 0 |
| 213 | index.php 죽이기!! [11] | 웅파 | 2011-11-07 | 3546 | 1 |
| 207 | 설정 - config.php 2편(마무리) [6] | 웅파 | 2011-11-01 | 2418 | 0 |
| 197 | 설정 - config.php 1편 [4] | 웅파 | 2011-10-27 | 2741 | 0 |
| 196 | 설정 - constants.php [2] | 웅파 | 2011-10-27 | 1706 | 0 |
| 193 | ci + jquery [4] | corean | 2011-10-18 | 1977 | 0 |
| 169 | phpfest 2011 codeigniter 강의 파일 [15] | 웅파 | 2011-05-29 | 3180 | 0 |
| 155 | CI 속도, 메모리, eAccelerator, Me.. [12] | tpae | 2011-04-30 | 3470 | 1 |
| 141 | Hook을 이용하여 웹과 모바일웹 만들기 2편 [7] | 웅파 | 2011-03-30 | 3114 | 0 |
| 140 | Hook을 이용하여 웹과 모바일웹 만들기 1편 [2] | 웅파 | 2011-03-30 | 3365 | 0 |
| 128 | [양승현]CI coding style guide 번역 [7] | 최용운 | 2011-01-09 | 2658 | 0 |
| 116 | CI의 사용자인증(User Authentication) [7] | Max | 2010-05-30 | 5093 | 0 |
| 112 | Selenium 명령어 정리 내용추가 [1] | 최용운 | 2010-05-20 | 2819 | 0 |
| 110 | Selenium UI 테스트툴 번역문서 [4] | 최용운 | 2010-05-19 | 3556 | 0 |
| 104 | [링크] CodeIgniter 동영상 강좌 (영어;.. [5] | 사월 | 2010-03-02 | 6032 | 0 |
| 100 | PHP 객체 강좌 (한글) [1] | corean | 2010-02-17 | 5150 | 0 |
| 99 | CodeIgniter Quick Reference .. [1] | corean | 2010-02-17 | 3710 | 0 |
| 97 | codeigniter + doctrine [1] | corean | 2010-02-04 | 3019 | 0 |

