https://imgur.com/yctZ3nx
이와같이 구현하고 싶어서 https://www.cosmosfarm.com/threads/document/20533 를 참고하였는데요
FTP로 접속해서 /wp-content/plugins/kboard/skin/사용중인스킨/list-category-tree-tab.php 파일에 있는 코드를 아래의 코드로 교체한 뒤,
<div class="kboard-tree-category-search">
<form id="kboard-tree-category-search-form-<?php echo $board->id?>" method="get" action="<?php echo $url->toString()?>">
<?php echo $url->set('pageid', '1')->set('target', '')->set('keyword', '')->set('mod', 'list')->toInput()?>
<input type="hidden" name="kboard_search_option[tree_category_1][key]" value="tree_category_1">
<input type="hidden" name="kboard_search_option[tree_category_1][value]" value="<?php echo $board->tree_category->getCategoryNameWithDepth(1)?>">
<input type="hidden" name="kboard_search_option[tree_category_2][key]" value="tree_category_2">
<input type="hidden" name="kboard_search_option[tree_category_2][value]" value="<?php echo $board->tree_category->getCategoryNameWithDepth(2)?>">
<div class="kboard-tree-category-wrap">
<?php $tree_category_list = $board->tree_category->getCategoryItemList()?>
<div class="kboard-search-option-wrap-1 kboard-search-option-wrap type-tab">
<ul class="kboard-tree-category">
<li<?php if(!$board->tree_category->getCategoryNameWithDepth(1)):?> class="kboard-category-selected"<?php endif?>><a href="#" onclick="return kboard_tree_category_search_all()"><?php echo __('All', 'kboard')?></a></li>
<?php foreach($tree_category_list as $item):?>
<li<?php if($board->tree_category->getCategoryNameWithDepth(1) == $item['category_name']):?> class="kboard-category-selected"<?php endif?>>
<a href="#" onclick="return kboard_tree_category_search_1dapth('<?php echo $item['category_name']?>')"><?php echo $item['category_name']?></a>
<?php
$sub_tree_category_list = array();
foreach($board->tree_category->tree_category as $sub_item){
if($item['id'] == $sub_item['parent_id']){
$sub_tree_category_list[] = $sub_item;
}
}
?>
<?php if($sub_tree_category_list):?>
<ul class="sub-tree-category">
<?php foreach($sub_tree_category_list as $sub_item):?>
<li<?php if($board->tree_category->getCategoryNameWithDepth(2) == $sub_item['category_name']):?> class="kboard-category-selected"<?php endif?>><a href="#" onclick="return kboard_tree_category_search_2dapth('<?php echo $item['category_name']?>', '<?php echo $sub_item['category_name']?>')"><?php echo $sub_item['category_name']?></a></li>
<?php endforeach?>
</ul>
<?php endif?>
</li>
<?php endforeach?>
</ul>
</div>
</div>
</form>
</div>
<script>
function kboard_tree_category_search_all(){
jQuery('input[name="kboard_search_option[tree_category_1][value]"]').val('');
jQuery('input[name="kboard_search_option[tree_category_2][value]"]').val('');
return kboard_tree_category_search('1', '');
}
function kboard_tree_category_search_1dapth(category1){
jQuery('input[name="kboard_search_option[tree_category_2][value]"]').val('');
return kboard_tree_category_search('1', category1);
}
function kboard_tree_category_search_2dapth(category1, category2){
jQuery('input[name="kboard_search_option[tree_category_1][value]"]').val(category1);
return kboard_tree_category_search('2', category2);
}
</script>
CSS 코드도 추가를 해주었습니다
#kboard-default-list .kboard-tree-category { overflow: visible; }
#kboard-default-list .kboard-tree-category>li { position: relative; }
#kboard-default-list .sub-tree-category { position: absolute; padding: 0; min-width: 200px; background-color: #f9f9f9; }
#kboard-default-list .sub-tree-category>li { display: block; margin: 0; padding: 0 5px; border: 0; list-style: none; }
#kboard-default-list .sub-tree-category>li::before,
#kboard-default-list .sub-tree-category>li::after { display: none; }
#kboard-default-list .sub-tree-category>li>a { font-weight: normal !important; border-bottom: 2px solid transparent !important; }
#kboard-default-list .sub-tree-category>li.kboard-category-selected a { font-weight: bold !important; }
#kboard-default-list .kboard-tree-category>li .sub-tree-category { display: none; }
#kboard-default-list .kboard-tree-category>li:hover .sub-tree-category { display: block; }
그런데 https://imgur.com/a/AvGv3KU 이렇게 밖에 구현이 안되네요ㅠㅠ
뭐가 문제인지 알려주시면 감사하겠습니다 (default 스킨입니다)
안녕하세요~^^
KBoard 플러그인에서 계층형 카테고리의 기본 스타일은 스킨마다 다릅니다.
디폴트 스킨에서는 계층형 카테고리 기본 레이아웃은 셀렉트 박스입니다.
탭 형식으로 교체하시려면
아래의 코드를 추가해보세요.
add_filter('kboard_skin_category_type', 'kboard_skin_category_type_20210506', 10, 3);
function kboard_skin_category_type_20210506($category_type, $board, $boardBuilder){
if($board->id == '1'){ // 실제 게시판 id로 적용해주세요.
$category_type = 'tree-tab';
}
return $category_type;
}
위의 코드에서 $board->id == '1' 부분은 실제 게시판 id로 적용해보세요.
테마의 functions.php 파일에 코드를 추가하거나 Code Snippets 플러그인을 사용해서 코드를 추가할 수 있습니다.
고맙습니다.