XpressEngine - 팁 공유 게시판
자신이 생각하기에는 아주 사소한 내용이라도 누군가에게는 큰 도움이 될 수 있습니다.
제로보드4 버전의 팁을 공유하고 싶으시다면 여기로~
제로보드 4 를 쓸때부터 홈페이지에 적용해서 쓰던 팝업창 소스를 제로보드 XE에서 적용하여 현재 쓰고 있는 방법입니다.
소스는 예전부터 여기저기 블로그 등에서 공개되었던 것으로 지금 현재도 사용시에 별문제가 없어서 계속 쓰고 있습니다.
다른 방법도 있으리라 생각되지만.. 혹 필요한 분이 계실까봐 조금이나마 도움이 되시라 올려봅니다.
우선 자신이 사용하고 있는 레이아웃의 디렉토리 속에 있는 JS 디렉토리 속의 xe_official.js 파일을 불러와서 편집을 합니다.
기본 레이아웃을 쓴다고 전제를 하고.. 기존의 xe_official.js 파일의 마지막 부분에 빨간 글씨 부분을 추가합니다.
// Hide And Show Toggle
var cc=0
function hideShow(id) {
if (cc==0) {
cc=1
document.getElementById(id).style.display="none";
} else {
cc=0
document.getElementById(id).style.display="block";
}
}
// Show And Hide Toggle
var cc=0
function showHide(id) {
if (cc==0) {
cc=1
document.getElementById(id).style.display="block";
} else {
cc=0
document.getElementById(id).style.display="none";
}
}
// Local Navigation Toggle
function lnbToggle(id) {
for(num=1; num<=3; num++) document.getElementById('D3MG'+num).style.display='none'; //D4MG1~D4MG3 까지 숨긴 다음
document.getElementById(id).style.display='block'; //해당 ID만 보임
}
// IS
function chkIsKind(key, value) {
showHide('selectOrder');
xGetElementById('search_target'+key).checked = true;
xInnerHtml('search_target_label', value);
}
//팝업창
function getCookie(name) //쿠키의 존재 유무를 알아내는 함수를 만듭니다.
{
var nameOfCookie = name + "=";
var x = 0;
while(x <= document.cookie.length)
{
var y = (x + nameOfCookie.length);
if(document.cookie.substring(x,y) == nameOfCookie)
{
if((endOfCookie = document.cookie.indexOf(";",y)) == -1)
endOfCookie = document.cookie.length;
return unescape(document.cookie.substring(y,endOfCookie));
}
x = document.cookie.indexOf(" ",x) + 1;
if(x == 0)
break;
}
return "";
}
if (getCookie("no_pop") != "ok" ) //no_pop 이라는 이름의 쿠키값이 ok 가 아니라면 다음의 새창 띄우기를 실행
{
window.open("pop_up.htm","hi", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width = 360 height = 320"); //파일 이름과 속성을 자신에 맞게 수정하면 됩니다.
}
제일 마지막 부분의 width=360 height=320 은 팝업창의 크기이니 원하는 크기로 지정하시면 됩니다.
추가가 되었으면 저장을 하시고 그 파일을 서버에 있는 같은 위치의 xe_official.js 파일에 덮어쓰기를 합니다.
이제 팝업창을 제작합니다.
새파일을 만들어서 다음 빨간 글씨를 복사해서 붙여 넣은 다음 원하는 팝업창 메세지를 작성하시고
pop_up.htm으로 저장합니다. 그 pop_up.htm 파일을 서버에 zbxe 디렉토리에 업로드 시키면 됩니다.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>타이틀 제목</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<SCRIPT language="JavaScript">
<!--
function setCookie(name,value,expiredays) //쿠키를 사용자에게 전달할 함수만들기
//setCookie(쿠키이름,쿠키값,쿠키만료시간)
{
var todayDate = new Date();
todayDate.setDate(todayDate.getDate() + expiredays);
document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}
function closeWin()
{
if (cookie_form.chk.checked) //체크박스에 체크되 있다면(폼 이름,체크박스 이름을 맞춰주세요.)
setCookie("no_pop","ok",1); //쿠키이름은 no_pop,쿠키값은 ok,쿠키만료 기간은 1 일로 쿠키생성
//혹시 no_pop 이라는 이름의 쿠키를 이미 사용하고 있다면 이름을 바꿔주세요
self.close(); //창 닫기
}
// -->
</SCRIPT>
</head>
<body>
이곳에 원하시는 메세지를 편집해서 써 넣으시고..
<form name = "cookie_form">
<div align="right">
<input type = "checkbox" name = "chk">
<font size="2" face="굴림" color="#003366"><strong>오늘 다시 열지 않기</strong></font>
<input type = "button" value = "Close" onClick = "closeWin();">
</div>
</form>
</body>
</html>
설명이 제대로 됐나 모르겠네요.
초보가 맨날 도움만 받다가 혹시나 필요하신분이 계신것 같아서 용기내어 올려봅니다.
pop_up.htm 속 위치 맞습니다.
<form name = "cookie_form">
<div align="right">
<input type = "checkbox" name = "chk">
<font size="2" face="굴림" color="#003366"><strong>오늘 다시 열지 않기</strong></font>
<input type = "button" value = "Close" onClick = "closeWin();">
</div>
</form>
이부분은 없어도 팝업창이 떠야하는데요..
제공해 주신 소스 js 파일 중간쯤에 " } " 하나 추가 했고요 . 안됩니다. 소스 한번 봐주세요.
pop_up.htm 도 업로드했습니다.
레이아웃 라운드하우스 layout.js 파일입니다.
xAddEventListener(window,'load',setBarImageHeight);
xAddEventListener(document,'mouseover',showSubMenu);
function setBarImageHeight() {
var height = xHeight("contentMain");
var clientHeight = xClientHeight();
if(clientHeight>height) height = clientHeight;
else height+=40;
var leftImg = xGetElementById("contentLeftBar");
xHeight(leftImg, height);
xHeight(leftImg.parentNode, height);
var rightImg = xGetElementById("contentRightBar");
xHeight(rightImg, height);
xHeight(rightImg.parentNode, height);
}
var prevSubObj = null;
function showSub(obj) {
if(prevSubObj) prevSubObj.style.display = 'none';
obj.style.display = "block";
prevSubObj = obj;
}
function closeSub(obj) {
if(prevSubObj) {
prevSubObj.style.display = 'none';
prevSubObj = null;
}
}
function showSubMenu(evt){
var e = new xEvent(evt);
var obj = e.target;
var parent = null;
if(obj.nodeName == 'A' && obj.parentNode) {
parent = obj.parentNode.parentNode;
} else if(obj.nodeName == 'DIV') {
parent = obj.parentNode;
}
if(!parent || !parent.id || !/^main_menu_[0-9]+/.test(parent.id)) {
closeSub(obj);
return;
}
var id = parent.id.replace(/^main_menu_/,'');
var subObj = xGetElementById('sub_'+id);
if(!subObj) {
closeSub(obj);
return;
}
if(subObj.style.display != 'block') {
subObj.style.right = 0;
subObj.style.top = 0;
showSub(subObj);
}
}
//팝업창
function getCookie(name) //쿠키의 존재 유무를 알아내는 함수를 만듭니다.
{
var nameOfCookie = name + "=";
var x = 0;
while(x <= document.cookie.length)
{
var y = (x + nameOfCookie.length);
if(document.cookie.substring(x,y) == nameOfCookie)
{
if((endOfCookie = document.cookie.indexOf(";",y)) == -1)
endOfCookie = document.cookie.length;
return unescape(document.cookie.substring(y,endOfCookie));
}
x = document.cookie.indexOf(" ",x) + 1;
if(x == 0)
break;
}
return "";
}
if (getCookie("no_pop") != "ok" ) //no_pop 이라는 이름의 쿠키값이 ok 가 아니라면 다음의 새창 띄우기를 실행
{
window.open("pop_up.htm","hi", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, //팝업창
}
function getCookie(name) //쿠키의 존재 유무를 알아내는 함수를 만듭니다.
{
var nameOfCookie = name + "=";
var x = 0;
while(x <= document.cookie.length)
{
var y = (x + nameOfCookie.length);
if(document.cookie.substring(x,y) == nameOfCookie)
{
if((endOfCookie = document.cookie.indexOf(";",y)) == -1)
endOfCookie = document.cookie.length;
return unescape(document.cookie.substring(y,endOfCookie));
}
x = document.cookie.indexOf(" ",x) + 1;
if(x == 0)
break;
}
return "";
}
if (getCookie("no_pop") != "ok" ) //no_pop 이라는 이름의 쿠키값이 ok 가 아니라면 다음의 새창 띄우기를 실행
{
window.open("pop_up.htm","hi", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width = 360 height = 320"); //파일 이름과 속성을 자신에 맞게 수정하면 됩니다.
}
팝업창이 순간적으로 뜨더니 메인페이지 뒤로 가버리네요.
왜 그럴까요. 제가 아무래도 문제겠지요?





적당한 위치를 찾아서 다음 소스를 넣어주시면 됩니다. <<<적당한 위치라는게..pop_up.htm안에 위치를 말씀하시는건가요??
기본레이아웃이 아니라서 그런지.....팝업이 뜨질않네요...ㅜ.ㅜ 레이아웃에 있던 가가채팅도 안뜨고....ㅜ.ㅜ