제목 | 흠..헤더 질문입니다. | ||
---|---|---|---|
카테고리 | CI 2, 3 | ||
글쓴이 | 소연신 | 작성시각 | 2017/05/30 14:04:32 |
|
|||
뭔가 질문이 다시 옛날로 돌아간 느낌이네요 ㅎㅎ
일단.. 지금 헤더 분(body윗부분)을 클래스로 만들어서 주소별로 js랑 css 로드하고 있습니다. MY_Controller에 remap정의해서 공통헤더로요. 근데... 이렇게 하지말고 개별헤더로 사용하라고 하더라구요. 뭐, 불필요한 js가 로드될수도 있고, 조건을 계속 줘야되고, 뎁쓰가 무너지고..뭐 여러 이유였습니다.
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Header { function __construct() { $CI =& get_instance(); $this->segment1 = $CI->uri->segment(1); $this->segment2 = $CI->uri->segment(2); $this->segment3 = $CI->uri->segment(3); } function load_Css() { return $this->loadCss(); } function load_Js() { return $this->loadJs(); } function load_HeadTag() { return $this->headTag(); } function load_Header() { return $this->header(); } protected function header() { $result = ''; $result = $result.'<!doctype html>'."\n"; $result = $result.'<html lang="en">'."\n"; $result = $result.' <head>'."\n"; $result = $result.' <meta charset="UTF-8">'."\n"; $result = $result.' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'."\n"; $result = $result.' <title>pickdol</title>'."\n"; return $result; } protected function headTag() { $result = ''; if ($this->segment1 != 'Admin' && $this->segment2 != 'Ajax_admin' && $this->segment2 != 'Ajax_admin_bean' && $this->segment2 != 'Ajax_admin_bet' && $this->segment2 != 'Ajax_admin_coin' && $this->segment2 != 'Ajax_admin_ip' && $this->segment2 != 'Ajax_admin_item' && $this->segment2 != 'Ajax_admin_level' && $this->segment2 != 'Ajax_admin_memo' && $this->segment2 != 'Ajax_admin_point' && $this->segment2 != 'Ajax_admin_stats' && $this->segment2 != 'Ajax_admin_accesslog' && $this->segment3 != 'get_game_result' && $this->segment3 != 'get_game_rate' ) { // 접속 ip set_access_ip_write(); } $result = $result.' <link href="/static/images/.ico" type="image/x-icon" rel="shortcut icon" />'."\n"; $result = $result.' <link href="/static/css/alertify.css" rel="stylesheet" />'."\n"; if ($this->segment1 != 'Admin') { $result = $result.' <link href="/static/css/layout.css" rel="stylesheet" />'."\n"; } if ($this->segment1 == 'Main' || $this->segment1 == '') { $result = $result.' <meta name="naver-site-verification" />'."\n"; $result = $result.' <meta name="Keywords" >'."\n"; $result = $result.' <meta name="description" >'."\n"; $result = $result.' <meta property="og:type" content="website">'."\n"; $result = $result.' <meta property="og:image">'."\n"; $result = $result.' <meta property="og:title" content="">'."\n"; $result = $result.' <meta property="og:keywords" >'."\n"; $result = $result.' <meta property="og:description" ">'."\n"; } $result = $result.' <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.js"></script>'."\n"; $result = $result.' <script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script>'."\n"; $result = $result.' <script src="//cdn.jsdelivr.net/alertifyjs/1.9.0/alertify.min.js"></script>'."\n"; $result = $result.' <script src="/static/js/common.js"></script>'."\n"; return $result; } protected function loadCss() { $result = ''; switch ($this->segment1) { case 'Main': case '': $result = ' <link href="/static/css/main.css" rel="stylesheet" />'; break; case 'User': $result = ' <link href="/static/css/user.css" rel="stylesheet" />'; break; case 'Chatting': $result = ' <link href="/static/css/chat.css" rel="stylesheet" />'; break; case 'Board': $result = ' <link href="/static/css/board.css" rel="stylesheet" />'; break; case 'Mypage': $result = ' <link href="/static/css/mypage.css?v=201705" rel="stylesheet" />'; break; case 'Market': $result = ' <link href="/static/css/market.css" rel="stylesheet" />'; break; case 'Game': $result = ' <link href="/static/css/game_data.css" rel="stylesheet" />'; break; case 'Memo': $result = ' <link href="/static/css/memo.css" rel="stylesheet" />'; break; case 'Admin': $result = ' <link href="/static/css/admin.css" rel="stylesheet" />'; break; case 'Rank': $result = ' <link href="/static/css/rank.css" rel="stylesheet" />'; break; case 'Livegame': $result = ' <link href="/static/css/live_game.css" rel="stylesheet" />'; break; default: # code... break; } return $result; } protected function loadJs() { $result = ''; switch ($this->segment1) { case 'Main': case '': case 'User': $result = ' <script src="/static/js/user.js"></script>'."\n"; break; case 'Board': $result = ' <script src="/static/js/board.js"></script>'."\n"; $result = $result.' <script src="/static/js/board_draw.js"></script>'."\n"; $result = $result.' <script src="/static/js/paging.js"></script>'."\n"; break; case 'Mypage': $result = ' <script src="/static/js/mypage.js?v=201705"></script>'."\n"; $result = $result.' <script src="/static/js/paging.js"></script>'."\n"; break; case 'Market': $result = ' <script src="/static/js/market.js?v=201705"></script>'."\n"; break; case 'Game': if ($this->segment3) { $result = ' <script src="/static/js/stats_'.$this->segment3.'.js"></script>'."\n"; } break; case 'Memo': $result = ' <script src="/static/js/memo.js?v=201705"></script>'."\n"; $result = $result.' <script src="/static/js/paging.js"></script>'."\n"; break; case 'Admin': if ($this->segment3 == 'members_whole' || $this->segment3 == 'members_block' || $this->segment3 == 'members_withdrawal') { //$result = '<script src="/static/js/admin_point.js"></script>'; } else if ($this->segment3 == 'coinpayment_list' || $this->segment3 == 'coin_list' || $this->segment3 == 'coin_pay' || $this->segment3 == 'account_info') { $result = ' <script src="/static/js/admin_coin.js"></script>'."\n"; } else if ($this->segment3 == 'rc_list' || $this->segment3 == 'rc_exchange' || $this->segment3 == 'rc_pay' || $this->segment3 == 'rc_set') { $result = ' <script src="/static/js/admin_bean.js"></script>'."\n"; } else if ($this->segment3 == 'point_list' || $this->segment3 == 'point_pay' || $this->segment3 == 'point_set') { $result = ' <script src="/static/js/admin_point.js"></script>'."\n"; } else if ($this->segment3 == 'item_list' || $this->segment3 == 'item_pay' || $this->segment3 == 'itembuy_list') { $result = ' <script src="/static/js/admin_item.js"></script>'."\n"; } else if ($this->segment3 == 'class_view' || $this->segment3 == 'class_point_list' || $this->segment3 == 'class_point_pay' || $this->segment3 == 'class_point_set') { $result = ' <script src="/static/js/admin_level.js"></script>'."\n"; } else if ($this->segment3 == 'message_list' || $this->segment3 == 'message_confirm' || $this->segment3 == 'message_write') { $result = ' <script src="/static/js/admin_memo.js"></script>'."\n"; } else if ($this->segment3 == 'ip_access' || $this->segment3 == 'ip_block') { $result = ' <script src="/static/js/admin_ip.js"></script>'."\n"; } else if ($this->segment3 == 'best' || $this->segment3 == 'free' || $this->segment3 == 'tip' || $this->segment3 == 'humor' || $this->segment3 == 'photo' || $this->segment3 == 'sports' || $this->segment3 == 'entry' || $this->segment3 == 'reply' || $this->segment3 == 'accuse' || $this->segment3 == 'notice' || $this->segment3 == 'qna' || $this->segment2 == 'boardView') { $result = ' <script src="/static/js/admin_board.js?v='.time().'"></script>'."\n"; $result = $result.' <script src="/static/js/admin_board_draw.js"></script>'."\n"; } else if ($this->segment3 == 'site_popup') { $result = ' <script src="/static/js/popup.js"></script>'."\n"; } else if ($this->segment3 == 'site_imagebanner') { $result = ' <script src="/static/js/banner.js"></script>'."\n"; } else if ($this->segment3 == 'stats') { $result = ' <script src="/static/js/admin_stat.js"></script>'."\n"; } else if ($this->segment3 == 'bet_betting' || $this->segment3 == 'bet_rank') { $result = ' <script src="/static/js/admin_bet.js"></script>'."\n"; } $result = $result.' <script src="/static/js/paging.js"></script>'."\n"; $result = $result.' <script src="/static/js/admin.js"></script>'."\n"; $result = $result.' <script src="/static/js/admin_draw.js"></script>'."\n"; break; case 'Test': $result = ''; break; case 'Rank': $result = ' <script src="/static/js/rank.js?v=20170515"></script>'."\n"; $result = $result.' <script src="/static/js/paging.js"></script>'."\n"; break; case 'Livegame': $result = ' <script src="/static/js/livegame.js"></script>'."\n"; break; default: # code... break; } if($this->segment1 != 'Admin') { $result = $result.' <script src="/static/js/jquery.bxslider.min.js"></script>'."\n"; $result = $result.' <script src="/static/js/publish.js"></script>'."\n"; $result = $result.' <script src="/static/js/popup.js"></script>'."\n"; $result = $result.' <script src="/static/js/banner.js"></script>'."\n"; $result = $result.' <script>window.alert = null</script>'."\n"; } return $result; } } 기존에 사용하던 공통헤더입니다. 다른 분들은 헤더 부분을 어떻게 관리하는지 궁금합니다. 공통헤더 말고 모든 페이지마다 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title></title> <script> window.serverInfo = { "host":"<?=$gchathost;?>", "port":80 }; </script> <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> </head> <body> <div id="isle"> </div> <script> </script> </body> </html> 그냥 이런식으로 사용하라는데..솔직히 이해가 잘 안가서요. 여러분들은 어떻게 하시는지 의견을 듣고 싶습니다. |
|||
다음글 | $this->db->close(); 이거 꼭... (3) | ||
이전글 | db 수동연결시 폼 검증에 대해 여쭤보고 싶습니다. (2) | ||
한대승(불의회상)
/
2017/05/30 14:20:49 /
추천
0
레이아웃을 만들고 레이아웃별로 관리하고 있습니다.
|
변종원(웅파)
/
2017/05/30 14:24:33 /
추천
0
헤더, 푸터는 웹, 모바일, 팝업용도로 3개 사용하고 내부에서 분기처리합니다. _remap 에서 선언해서 사용합니다. 간결하고 눈에 잘 띄도록 하는게 중요하다고 생각하는 1인이라서요. |