포털 사이트는 시즌마다 로고를 자동으로 어떻게 바꾸는지 궁금합니다.
얼마전 크리스마스때 머리를 굴리다가...
로고 부분을 직접바꾸는 것 보다는 로고 배경 및 다른 글씨체들도 바꿀 수도 있을 듯 싶어서
시즌별로 css 파일을 바꾸도록 해봤습니다.
head.sub.php 파일 상단에 style.css을 불러오는 부분에 조건을 걸어서
신년, 구정, 추석, 크리스마스 이런식으로 다른 style.css 를 불러오게끔 해봤습니다.
저는 g4_config 테이블 여분필드를 다른 부분에 사용하고 있어서 그냥 cf_logo_change 필드(varchar(255))를 하나 만들었습니다.
관리자모드에서
css 파일명(style파일명.css) | 시작날짜 | 종료날짜
이런식으로 지정해서 array?로 저장되도록 했습니다.
현재 필드값을 보면 이렇게 나오네요.
_0101|1230|0102|_0201|0115|0202||0901|0915|_1225|1201|1226
설명하자면, 신년에는 12월30일에 style_0101.css 파일을 불러왔다가 01월02일날 다시 기본(style.css)으로 바꾸고,
... 크리스마스때는 12월01일에 style_1225.css 파일을 부르고 12월26일에 다시 기본으로 바꿉니다.
head.sub.php 파일 상단에는 이런식으로 넣어줬습니다.
---------------------------------------------------------------------------
<?
// =============== css를 구분하여 보여주기 위해 날짜 체크 ===============
$today_date = date("md",time());
// =============== css를 구분하여 보여주기 위해 날짜 체크 ===============
$today_date = date("md",time());
$temp_season = explode("|",$config[cf_logo_change]);
// 신년
$css1 = $temp_season[0];
$date_start1 = $temp_season[1];
$date_end1 = $temp_season[2];
// 설날
$css2 = $temp_season[3];
$date_start2 = $temp_season[4];
$date_end2 = $temp_season[5];
// 추석
$css3 = $temp_season[6];
$date_start3 = $temp_season[7];
$date_end3 = $temp_season[8];
// 크리스마스
$css4 = $temp_season[9];
$date_start4 = $temp_season[10];
$date_end4 = $temp_season[11];
// 신년
$css1 = $temp_season[0];
$date_start1 = $temp_season[1];
$date_end1 = $temp_season[2];
// 설날
$css2 = $temp_season[3];
$date_start2 = $temp_season[4];
$date_end2 = $temp_season[5];
// 추석
$css3 = $temp_season[6];
$date_start3 = $temp_season[7];
$date_end3 = $temp_season[8];
// 크리스마스
$css4 = $temp_season[9];
$date_start4 = $temp_season[10];
$date_end4 = $temp_season[11];
// ############# 신년 기간인지 체크 (12월에서 1월로 넘어가므로 따로체크) #############
if ($today_date >= $date_start1 || ($today_date >= 0101 && $today_date < $date_end1)) {
?>
<link rel="stylesheet" href="<?=$g4['path']?>/style<?=$css1?>.css" type="text/css">
<?
} else {
// ############# 신년 이외의 기간 체크 #############
$css_chk = ""; // 해당 기간 체크용
for ($k=2; $k<=4; $k++) {
if ($today_date >= ${'date_start'.$k} && $today_date < ${'date_end'.$k}) { // 신년 이외
$css_chk = "ok"; // 해당 기간이 있다면 ok
?>
<link rel="stylesheet" href="<?=$g4['path']?>/style<?=${'css'.$k}?>.css" type="text/css">
<?
}
}
if (!$css_chk) { // for문 내에서 해당 기간이 없었다면 기본 css선택
?>
<link rel="stylesheet" href="<?=$g4['path']?>/style.css" type="text/css">
<?
}
}
if ($today_date >= $date_start1 || ($today_date >= 0101 && $today_date < $date_end1)) {
?>
<link rel="stylesheet" href="<?=$g4['path']?>/style<?=$css1?>.css" type="text/css">
<?
} else {
// ############# 신년 이외의 기간 체크 #############
$css_chk = ""; // 해당 기간 체크용
for ($k=2; $k<=4; $k++) {
if ($today_date >= ${'date_start'.$k} && $today_date < ${'date_end'.$k}) { // 신년 이외
$css_chk = "ok"; // 해당 기간이 있다면 ok
?>
<link rel="stylesheet" href="<?=$g4['path']?>/style<?=${'css'.$k}?>.css" type="text/css">
<?
}
}
if (!$css_chk) { // for문 내에서 해당 기간이 없었다면 기본 css선택
?>
<link rel="stylesheet" href="<?=$g4['path']?>/style.css" type="text/css">
<?
}
}
음... 제가 초보수준이라 머리굴려도 이런방식뿐이 안떠오르네요.
단... 구정과 추석 날짜 넣어줄때 음력계산을 하도록 했으면 하는데 손이 안가네요. ㅜㅜ
시간 나면 해놔야할 것 같은데...
아직 음력, 양력 선택을 안넣어서 파일들은 안올렸습니다.
다른 쉬운 방법이 있지 않을까... 다른 방법들을 찾아보고 있습니다.
--------------------------------------------------------------------------
참! 저는 head.php 파일내에 로고부분 처리를 이렇게 했습니다.
<td width="280" align="center" valign="bottom" class="top_logo"><a href="/" class="text_hid" title="홈페이지 URL" onFocus="this.blur()">홈페이지 URL</a></td>
기본 style.css 파일에는
.top_logo { width: 200px; height: 50px; padding:0 40px 0 40px; }
.top_logo a {
background: url("/img/logo.png") no-repeat;
width: 200px; height: 50px; border:0; display: block;
}
.text_hid { text-indent: -10000px; overflow: hidden; width: 1px; height: 1px; font-size: 1px; line-height: 1px; float: left; }
.top_logo a {
background: url("/img/logo.png") no-repeat;
width: 200px; height: 50px; border:0; display: block;
}
.text_hid { text-indent: -10000px; overflow: hidden; width: 1px; height: 1px; font-size: 1px; line-height: 1px; float: left; }
댓글 8개
게시글 목록
| 번호 | 제목 |
|---|---|
| 34021 | |
| 33994 | |
| 33922 | |
| 33895 | |
| 33889 | |
| 33882 | |
| 33868 |
최신글
최신글 함수 개량
11
|
| 33863 | |
| 33859 | |
| 33857 | |
| 33849 | |
| 33842 | |
| 33835 | |
| 33830 | |
| 33828 | |
| 33807 | |
| 33797 | |
| 33796 | |
| 33791 | |
| 33786 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기