http://www.cosmosfarm.com/threads/document/11756
안녕하세요
위 url 에서 2차 카테고리에 관한 내용을 보고 잘 적용하였습니다
그런데 해당 글에는 list 부분에 대한 소스만 있고 (쓰기)에 해당하는 소스는 없는 것 같습니다
이 부분도 꼭 좀 부탁드립니다 ㅠㅠ
감사합니다
안녕하세요~^^
스킨의 editor.php 파일을 수정해주세요.
FTP로 접속헤서 /wp-content/plugins/kboard/skin/사용중인스킨/editor.php 파일입니다.
1. 아래 코드를 찾아주세요.
<?php if($board->use_category):?>
<?php if($board->initCategory1()):?>
<div class="kboard-attr-row">
<label class="attr-name" for="kboard-select-category1"><?php echo __('Category', 'kboard')?>1</label>
<div class="attr-value">
<select id="kboard-select-category1" name="category1">
<option value=""><?php echo __('Category', 'kboard')?> <?php echo __('Select', 'kboard')?></option>
<?php while($board->hasNextCategory()):?>
<option value="<?php echo $board->currentCategory()?>"<?php if($content->category1 == $board->currentCategory()):?> selected<?php endif?>><?php echo $board->currentCategory()?></option>
<?php endwhile?>
</select>
</div>
</div>
<?php endif?>
<?php if($board->initCategory2()):?>
<div class="kboard-attr-row">
<label class="attr-name" for="kboard-select-category2"><?php echo __('Category', 'kboard')?>2</label>
<div class="attr-value">
<select id="kboard-select-category2" name="category2">
<option value=""><?php echo __('Category', 'kboard')?> <?php echo __('Select', 'kboard')?></option>
<?php while($board->hasNextCategory()):?>
<option value="<?php echo $board->currentCategory()?>"<?php if($content->category2 == $board->currentCategory()):?> selected<?php endif?>><?php echo $board->currentCategory()?></option>
<?php endwhile?>
</select>
</div>
</div>
<?php endif?>
<?php endif?>
2. 위에서 찾은 코드를 아래 코드로 교체해주세요.
<?php if($board->use_category):?>
<?php
// 이 부분의 코드를 적절히 수정해주세요.
$category2 = array(
'홍콩생활' => array('홍콩생활1','홍콩생활2'),
'홍콩여행' => array('홍콩여행1','홍콩여행2'),
'업체리스트' => array('업체리스트1','업체리스트2'),
'스토어' => array('스토어1','스토어2'),
);
?>
<?php if($board->initCategory1()):?>
<div class="kboard-attr-row">
<label class="attr-name" for="kboard-select-category1"><?php echo __('Category', 'kboard')?>1</label>
<div class="attr-value">
<select id="kboard-select-category1" name="category1" onchange="kboard_update_category2(this.value)">
<option value=""><?php echo __('Category', 'kboard')?> <?php echo __('Select', 'kboard')?></option>
<?php while($board->hasNextCategory()):?>
<option value="<?php echo $board->currentCategory()?>"<?php if($content->category1 == $board->currentCategory()):?> selected<?php endif?>><?php echo $board->currentCategory()?></option>
<?php endwhile?>
</select>
</div>
</div>
<?php endif?>
<?php
if($content->category1 && $category2[$content->category1]){
$board->category = $category2[$content->category1];
}
else{
$board->category = array();
}
?>
<div class="kboard-attr-row">
<label class="attr-name" for="kboard-select-category2"><?php echo __('Category', 'kboard')?>2</label>
<div class="attr-value">
<select id="kboard-select-category2" name="category2">
<option value=""><?php echo __('Category', 'kboard')?> <?php echo __('Select', 'kboard')?></option>
<?php foreach($board->category as $current_category):?>
<option value="<?php echo $current_category?>"<?php if($content->category2 == $current_category):?> selected<?php endif?>><?php echo $current_category?></option>
<?php endforeach?>
</select>
</div>
</div>
<script>
function kboard_update_category2(category1){
var category2 = <?php echo json_encode($category2)?>;
var index = 0;
document.getElementById('kboard-select-category2').options = [];
document.getElementById('kboard-select-category2').options[index++] = new Option('<?php echo __('Category', 'kboard')?> <?php echo __('Select', 'kboard')?>', '');
if(category2[category1].length){
var category2_list = category2[category1];
for(var category2_index in category2_list){
document.getElementById('kboard-select-category2').options[index++] = new Option(category2_list[category2_index], category2_list[category2_index]);
}
}
}
</script>
<?php endif?>
게시판 관리에서 카테고리1 설정은 미리 등록되어 있어야 합니다.
고맙습니다.