분류3 - 분류3_2 - 분류3_2_2 | 3단분류
페이지 정보
작성자 최고관리자 작성일17-11-14 13:36 조회28,656회 댓글0건관련링크
본문
/**
* 관리자에서 게시판 카타고리에 1차 분류 등록 ex) 분류1|분류2
* 2차 분류 wr_1, 3차 분류 wr_2 사용 (자바스크립트에서 cate 배열로 생성)
* common.js, list.skin.php, write.skin.php 하단에 삽입, view.skin.php 수정
*/
/*************************************************************
* /js/common.js 하단 삽입
*************************************************************/
var cate = [];
cate['분류1'] = ['분류1_1', '분류1_2'];
cate['분류2'] = ['분류2_1', '분류2_2'];
cate['분류3'] = ['분류3_1', '분류3_2'];
cate['분류1_1'] = ['분류1_1_1', '분류1_1_2'];
cate['분류1_2'] = ['분류1_2_1', '분류1_2_2'];
cate['분류2_1'] = ['분류2_1_1', '분류2_1_2'];
cate['분류2_2'] = ['분류2_2_1', '분류2_2_2'];
cate['분류3_1'] = ['분류3_1_1', '분류3_1_2'];
cate['분류3_2'] = ['분류3_2_1', '분류3_2_2'];
/*************************************************************
* /skin/board/basic/list.skin.php 하단 삽입
*************************************************************/
<script>
var m, eq =0, val, html = '', sca ='<?php echo $sca ?>', stx;
// 1차 분류 받아오기
cate[0] = [];
$('#bo_cate_ul li').each( function() {
if ($(this).text() == '전체') return;
cate[0].push( $(this).text().replace(/열린 분류 /, '') );
})
// select box 배치
$('#bo_cate_ul').html('<select name="sca" id="sca" class="sca"></select');
$('#sca').after(' <select name="wr_1" id="wr_1" class="sca"></select> <select name="wr_2" id="wr_2" class="sca"></select> <input type="button" id="cate_sh" value="검색" />');
// 1차 분류 세팅
getOption(eq, 0, sca);
m = /wr_(\d)&stx=(.+)/.exec(location.href);
if (m) {
eq = m[1];
stx = decodeURIComponent(m[2]); // 분류값
}
// 2차, 3차 분류 세팅
if (stx) {
val = stx;
while (eq) {
for (var i in cate) {
if ((cate[i] + ',') . indexOf(val + ',' ) > -1) {
getOption(eq, i, val);
if (m[1] == 1) getOption(Number(eq) + 1, val);
val = i;
}
}
eq--;
}
} else {
getOption(++eq, sca);
}
// option 생성
function getOption(eq, i, val = '') {
if (typeof cate[i] == 'undefined') return;
var html = '<option value="">전체</option>';
for (var j in cate[i]) {
var selected = cate[i][j] == val ? 'selected' : '';
html += '<option value="' + cate[i][j] + '"' + selected + '>' + cate[i][j] + '</option>';
}
$('.sca:eq(' + eq + ')').html(html);
}
// selected 값선택
$('.sca').on('change', function() {
$('.sca:gt(' + $(this).index() + ')').children('option').remove();
getOption($(this).index() + 1, this.value);
});
// submit
$('#cate_sh').on('click', function() {
var where = '&sca=' + $('#sca').val();
if ($('#wr_2').val())
where += '&sfl=wr_2&stx=' + $('#wr_2').val();
else if ($('#wr_1').val())
where += '&sfl=wr_1&stx=' + $('#wr_1').val();
else if ($('#sca').val() == '전체')
where = '';
location.href = location.href.replace(/&(sfl|stx|sca)=[^&]+/g, '') + where;
});
</script>
/*************************************************************
* /skin/board/basic/write.skin.php 하단 삽입
*************************************************************/
<script>
var cate1 = '<?php echo $ca_name ?>', cate2 = '<?php echo $wr_1 ?>', cate3 = '<?php echo $wr_2 ?>', step = 0, val = cate1;
// select box 배치
$('#ca_name').addClass('sca').after(' <select name="wr_1" id="wr_1" class="sca"></select> <select name="wr_2" id="wr_2" class="sca"></select>');
// 2차,3차 분류값
if (cate3) {
step = 2; val = cate3;
} else if (cate2) {
step = 1; val = cate2;
}
if (step < 2) {
getOption(step + 1, val);
}
// 2차, 3차 분류 세팅
while (step) {
for (var i in cate) {
if ( (cate[i] + ',') . indexOf(val + ',' ) > -1) {
getOption(step, i, val)
val = i;
}
}
step--;
}
// option 생성
function getOption(step, i, val = '') {
if (typeof cate[i] == 'undefined') return;
var html = '<option value="">전체</option>';
for (var j in cate[i]) {
var selected = cate[i][j] == val ? 'selected' : '';
html += '<option value="' + cate[i][j] + '"' + selected + '>' + cate[i][j] + '</option>';
}
$('#wr_' + step).html(html);
}
// selected 값선택
$('.sca').on('change', function() {
$('.sca:gt(' + $(this).index() + ')').children('option').remove();
getOption($(this).index() + 1, this.value);
});
</script>
/*************************************************************
* /skin/board/basic/view.skin.php 18 line 수정
*************************************************************/
if ($category_name) echo $view['ca_name'].' | '; // 분류 출력 끝
=>
if ($category_name) echo $view['ca_name'].' - ' . $view['wr_1'] . ' - ' . $view['wr_2'] . ' | '; // 분류 출력 끝
* 관리자에서 게시판 카타고리에 1차 분류 등록 ex) 분류1|분류2
* 2차 분류 wr_1, 3차 분류 wr_2 사용 (자바스크립트에서 cate 배열로 생성)
* common.js, list.skin.php, write.skin.php 하단에 삽입, view.skin.php 수정
*/
/*************************************************************
* /js/common.js 하단 삽입
*************************************************************/
var cate = [];
cate['분류1'] = ['분류1_1', '분류1_2'];
cate['분류2'] = ['분류2_1', '분류2_2'];
cate['분류3'] = ['분류3_1', '분류3_2'];
cate['분류1_1'] = ['분류1_1_1', '분류1_1_2'];
cate['분류1_2'] = ['분류1_2_1', '분류1_2_2'];
cate['분류2_1'] = ['분류2_1_1', '분류2_1_2'];
cate['분류2_2'] = ['분류2_2_1', '분류2_2_2'];
cate['분류3_1'] = ['분류3_1_1', '분류3_1_2'];
cate['분류3_2'] = ['분류3_2_1', '분류3_2_2'];
/*************************************************************
* /skin/board/basic/list.skin.php 하단 삽입
*************************************************************/
<script>
var m, eq =0, val, html = '', sca ='<?php echo $sca ?>', stx;
// 1차 분류 받아오기
cate[0] = [];
$('#bo_cate_ul li').each( function() {
if ($(this).text() == '전체') return;
cate[0].push( $(this).text().replace(/열린 분류 /, '') );
})
// select box 배치
$('#bo_cate_ul').html('<select name="sca" id="sca" class="sca"></select');
$('#sca').after(' <select name="wr_1" id="wr_1" class="sca"></select> <select name="wr_2" id="wr_2" class="sca"></select> <input type="button" id="cate_sh" value="검색" />');
// 1차 분류 세팅
getOption(eq, 0, sca);
m = /wr_(\d)&stx=(.+)/.exec(location.href);
if (m) {
eq = m[1];
stx = decodeURIComponent(m[2]); // 분류값
}
// 2차, 3차 분류 세팅
if (stx) {
val = stx;
while (eq) {
for (var i in cate) {
if ((cate[i] + ',') . indexOf(val + ',' ) > -1) {
getOption(eq, i, val);
if (m[1] == 1) getOption(Number(eq) + 1, val);
val = i;
}
}
eq--;
}
} else {
getOption(++eq, sca);
}
// option 생성
function getOption(eq, i, val = '') {
if (typeof cate[i] == 'undefined') return;
var html = '<option value="">전체</option>';
for (var j in cate[i]) {
var selected = cate[i][j] == val ? 'selected' : '';
html += '<option value="' + cate[i][j] + '"' + selected + '>' + cate[i][j] + '</option>';
}
$('.sca:eq(' + eq + ')').html(html);
}
// selected 값선택
$('.sca').on('change', function() {
$('.sca:gt(' + $(this).index() + ')').children('option').remove();
getOption($(this).index() + 1, this.value);
});
// submit
$('#cate_sh').on('click', function() {
var where = '&sca=' + $('#sca').val();
if ($('#wr_2').val())
where += '&sfl=wr_2&stx=' + $('#wr_2').val();
else if ($('#wr_1').val())
where += '&sfl=wr_1&stx=' + $('#wr_1').val();
else if ($('#sca').val() == '전체')
where = '';
location.href = location.href.replace(/&(sfl|stx|sca)=[^&]+/g, '') + where;
});
</script>
/*************************************************************
* /skin/board/basic/write.skin.php 하단 삽입
*************************************************************/
<script>
var cate1 = '<?php echo $ca_name ?>', cate2 = '<?php echo $wr_1 ?>', cate3 = '<?php echo $wr_2 ?>', step = 0, val = cate1;
// select box 배치
$('#ca_name').addClass('sca').after(' <select name="wr_1" id="wr_1" class="sca"></select> <select name="wr_2" id="wr_2" class="sca"></select>');
// 2차,3차 분류값
if (cate3) {
step = 2; val = cate3;
} else if (cate2) {
step = 1; val = cate2;
}
if (step < 2) {
getOption(step + 1, val);
}
// 2차, 3차 분류 세팅
while (step) {
for (var i in cate) {
if ( (cate[i] + ',') . indexOf(val + ',' ) > -1) {
getOption(step, i, val)
val = i;
}
}
step--;
}
// option 생성
function getOption(step, i, val = '') {
if (typeof cate[i] == 'undefined') return;
var html = '<option value="">전체</option>';
for (var j in cate[i]) {
var selected = cate[i][j] == val ? 'selected' : '';
html += '<option value="' + cate[i][j] + '"' + selected + '>' + cate[i][j] + '</option>';
}
$('#wr_' + step).html(html);
}
// selected 값선택
$('.sca').on('change', function() {
$('.sca:gt(' + $(this).index() + ')').children('option').remove();
getOption($(this).index() + 1, this.value);
});
</script>
/*************************************************************
* /skin/board/basic/view.skin.php 18 line 수정
*************************************************************/
if ($category_name) echo $view['ca_name'].' | '; // 분류 출력 끝
=>
if ($category_name) echo $view['ca_name'].' - ' . $view['wr_1'] . ' - ' . $view['wr_2'] . ' | '; // 분류 출력 끝
댓글목록
등록된 댓글이 없습니다.

