안녕하세요,
워드프레스 KBoard 게시판 리스트에 카테고리를 출력하려고 하는데요.
다른 분들이 질문하신 것 참고해도 잘 되지 않아서ㅠㅜ 글 남깁니다 ^^
사진처럼 번호 다음에 카테고리 부분을 넣고 싶은데요,
카테고리를 사용하고 있는 게시판도 있고 사용하지 않는 게시판도 있어서
카테고리 사용을 활성화 하는 경우에만 출력이 되게 하고 싶습니다.
list.php 파일에서
★★★....
위의 별 부분과,
★★★....
위의 별 부분. 두군데에 뭔가를 적어야 하는 것 같은데.. 맞나요?
작성하는 것 도와주시면 감사하겠습니다 ㅠㅠ
list.php 파일에 보시면 카테고리 코드가 있어서 응용하시면 됩니다^^
대략 만들어 드리자면
리스트 thead 부분에는 아래처럼.
<thead>
<tr>
<td class="kboard-list-uid"><?php echo __('Number', 'kboard')?></td>
<?php if($board->use_category == 'yes'):?>
<?php if($board->initCategory1()):?>
<td class="kboard-list-category1">카테고리1</td>
<?php endif?>
<?php if($board->initCategory2()):?>
<td class="kboard-list-category2">카테고리2</td>
<?php endif?>
<?php endif?>
<td class="kboard-list-title"><?php echo __('Title', 'kboard')?></td>
<td class="kboard-list-user"><?php echo __('Author', 'kboard')?></td>
<td class="kboard-list-date"><?php echo __('Date', 'kboard')?></td>
<td class="kboard-list-view"><?php echo __('Views', 'kboard')?></td>
</tr>
</thead>
리스트의 tbody 부분에는 아래처럼 해보세요.
<td class="kboard-list-uid"><?php echo $list->index()?></td>
<?php if($board->use_category == 'yes'):?>
<?php if($board->initCategory1()):?>
<td class="kboard-list-category1"><?php echo $content->category1?></td>
<?php endif?>
<?php if($board->initCategory2()):?>
<td class="kboard-list-category2"><?php echo $content->category2?></td>
<?php endif?>
<?php endif?>
<td class="kboard-list-title">
자세한 답변 감사합니다. 덕분에 한번에 해결되었습니다!!! ^^
카테고리 텝 수정 관련하여 질문이 더 있는데요,
thead의 '카테고리' 는 그대로 두고, tbody의 카테고리 항목 ( '제품', 'AS', '기타' 등)이 들어가는 부분만 글자 색상을 변경하고 싶습니다.
#kboard-joobong_default-list .kboard-list td.kboard-list-category1 {
등등 시도해봤는데 묶여있는지 tbody의 카테고리 부분만은 수정이 어렵네요. 어떻게 작성하면 될까요?ㅠㅜ
CSS 적용이 잘 안되시면 그냥 태그에 스타일 속성을 줘보세요^^
예를들면 아래처럼 그냥 직접적으로 적용해주세요.
<td class="kboard-list-category1" style="color:red"><?php echo $content->category1?></td>
그런데 리스트에서 보고 싶은 카테고리를 선택해도 필터되지 않고 전체가 출력됩니다.
확인 부탁드립니다 ㅠㅠ
http://www.joobong.com/new-products/
http://www.joobong.com/new-products/ 페이지에서
카테고리를 감싼 <form></form> 테그가 보이지 않는군요.
form이 없기 때문에 브라우저 주소창에 보시면 category1 등의 파라메터가 붙지 않고 있습니다.
아래 주소로 접속하면 카테고리가 필터되는걸 보실 수 있습니다.
http://www.joobong.com/new-products/?category1=JOOBONG
<form action=" 부분이 보이는데.. 이게 <form>과는 다른 건가요?
그리고 닫힌 부분도 뒷부분에 </form> 으로 잘 닫혀진 것 같아서요.
혹시 몰라서 <form action=" 앞에 <form> 을 붙여봤는데도 똑같습니다.
아래 한번 확인해주시겠어요?ㅠㅜ
<!-- 리스트 시작 -->
<div class="kboard-total-page">
<table>
<?php echo __('Total ')?>
<?php
global $wpdb;
echo $wpdb->get_var("SELECT COUNT(*) FROM `{$wpdb->prefix}kboard_board_content` WHERE `board_id`='{$board->id}'");
?>
<?php echo __('.')?>
</table>
</div>
<form action="<?php echo $url->set('category1', '')->set('category2', '')->set('paged', '1')->set('target', '')->set('keyword', '')->set('mod', 'list')->toInput()?>
<?php if($board->use_category == 'yes'):?>
<div class="kboard-category">
<?php if($board->initCategory1()):?>
<select name="category1" onchange="jQuery('#kboard-search-form').submit();">
<option value=""><?php echo __('All', 'kboard')?></option>
<?php while($board->hasNextCategory()):?>
<option value="<?php echo $board->currentCategory()?>"<?php if($_GET['category1'] == $board->currentCategory()):?> selected="selected"<?php endif?>><?php echo $board->currentCategory()?></option>
<?php endwhile?>
</select>
<?php endif?>
<?php if($board->initCategory2()):?>
<select name="category2" onchange="jQuery('#kboard-search-form').submit();">
<option value=""><?php echo __('All', 'kboard')?></option>
<?php while($board->hasNextCategory()):?>
<option value="<?php echo $board->currentCategory()?>"<?php if($_GET['category2'] == $board->currentCategory()):?> selected="selected"<?php endif?>><?php echo $board->currentCategory()?></option>
<?php endwhile?>
</select>
<?php endif?>
</div>
<?php endif?></form>
아래처럼 form에 id값을 추가해주셔야 정상적으로 jQuery('#kboard-search-form').submit() 이 코드가 실행됩니다.
<form id="kboard-search-form" action="<?php echo $url->set('category1', '')->set('category2', '')->set('paged', '1')->set('target', '')->set('keyword', '')->set('mod', 'list')->toInput()?>
코드 추가해서 테스트 해보시겠어요?
아직 오류가 나네요 ㅠㅠ
URL을 보면~
http://www.joobong.com/new-products/?category1=JOOBONG
이라고 주소가 되어야 정상인데 아래 주소로 됩니다.
http://www.joobong.com/new-products/%3Cinput%20type=?paged=1&category1=JOOBONG
(계속 도와주셔서 감사합니다♥)
소스보기 해서 확인해보니 오류가 있습니다.
아래 굵게 표시된 코드가 있으면 안됩니다.
스킨의 list.php 파일을 에디터로 열어서 확인해주세요.
<form id="kboard-search-form" action="<input type="hidden" name="mod" value="list"><input type="hidden" name="paged" value="1">
아래 처럼 해주셔야 합니다.
<form id="kboard-category-form-<?php echo $board->id?>" method="get" action="<?php echo $url->toString()?>">
<?php echo $url->set('pageid', '1')->set('category1', '')->set('category2', '')->set('target', '')->set('keyword', '')->set('mod', 'list')->toInput()?>
list.php 파일 내용을 올려주시면 어떻게 된건지 확인해보겠습니다.
안녕하세요, 제가 답변이 좀 늦었네요.
알려주신대로 수정을 했는데 아직 작동이 안되네요.
아래에 url과 함께 내용 올려드립니다^^
http://www.joobong.com/cs-center/11-qa/
<div id="kboard-joobong_default-list">
<!-- 리스트 시작 -->
<div class="kboard-total-page">
<table>
<?php echo __('Total ')?>
<?php
global $wpdb;
echo $wpdb->get_var("SELECT COUNT(*) FROM `{$wpdb->prefix}kboard_board_content` WHERE `board_id`='{$board->id}'");
?>
<?php echo __('.')?>
</table>
</div>
<form id="kboard-category-form-<?php echo $board->id?>" method="get" action="<?php echo $url->toString()?>">
<?php echo $url->set('pageid', '1')->set('category1', '')->set('category2', '')->set('target', '')->set('keyword', '')->set('mod', 'list')->toInput()?>
<?php if($board->use_category == 'yes'):?>
<div class="kboard-category">
<?php if($board->initCategory1()):?>
<select name="category1" onchange="jQuery('#kboard-search-form').submit();">
<option value=""><?php echo __('All', 'kboard')?></option>
<?php while($board->hasNextCategory()):?>
<option value="<?php echo $board->currentCategory()?>"<?php if($_GET['category1'] == $board->currentCategory()):?> selected="selected"<?php endif?>><?php echo $board->currentCategory()?></option>
<?php endwhile?>
</select>
<?php endif?>
<?php if($board->initCategory2()):?>
<select name="category2" onchange="jQuery('#kboard-search-form').submit();">
<option value=""><?php echo __('All', 'kboard')?></option>
<?php while($board->hasNextCategory()):?>
<option value="<?php echo $board->currentCategory()?>"<?php if($_GET['category2'] == $board->currentCategory()):?> selected="selected"<?php endif?>><?php echo $board->currentCategory()?></option>
<?php endwhile?>
</select>
<?php endif?>
</div>
<?php endif?></form>
<div class="kboard-list">
<table>
<thead>
<tr>
<td class="kboard-list-uid"><?php echo __('Number', 'kboard')?></td>
<?php if($board->use_category == 'yes'):?>
<?php if($board->initCategory1()):?>
<td class="kboard-list-category1">카테고리</td>
<?php endif?>
<?php if($board->initCategory2()):?>
<td class="kboard-list-category2">카테고리2</td>
<?php endif?>
<?php endif?>
<td class="kboard-list-title"><?php echo __('Title', 'kboard')?></td>
<td class="kboard-list-user"><?php echo __('Author', 'kboard')?></td>
<td class="kboard-list-date"><?php echo __('Date', 'kboard')?></td>
<td class="kboard-list-view"><?php echo __('Views', 'kboard')?></td>
</tr>
</thead>
<tbody>
<?php while($content = $list->hasNextNotice()):?>
<tr class="kboard-list-notice">
<td class="kboard-list-uid"><?php echo __('Notice', 'kboard')?></td>
<?php if($board->use_category == 'yes'):?>
<?php if($board->initCategory1()):?>
<td class="kboard-list-category1"><?php echo $content->category1?></td>
<?php endif?>
<?php if($board->initCategory2()):?>
<td class="kboard-list-category2"><?php echo $content->category2?></td>
<?php endif?>
<?php endif?>
<td class="kboard-list-title">
<a href="<?php echo $url->set('uid', $content->uid)->set('mod', 'document')->toString()?>">
<div class="kboard-joobong_default-cut-strings">
<?php echo $content->title?>
<?php echo $content->getCommentsCount()?>
<?php if($content->secret):?><img src="<?php echo $skin_path?>/images/icon-lock.png" alt="<?php echo __('Secret', 'kboard')?>"><?php endif?>
<?php if($content->isNew()):?><span class="kboard-joobong_default-new-notify">New</span><?php endif?>
</div>
<div class="kboard-mobile-contents">
<span class="contents-item"><img src="<?php echo $skin_path?>/images/icon-user.png" alt="<?php echo __('Author', 'kboard')?>"> <?php echo $content->member_display?></span>
<span class="contents-item"><img src="<?php echo $skin_path?>/images/icon-date.png" alt="<?php echo __('Date', 'kboard')?>"> <?php echo date("Y.m.d", strtotime($content->date))?></span>
<span class="contents-item"><img src="<?php echo $skin_path?>/images/icon-view.png" alt="<?php echo __('Views', 'kboard')?>"> <?php echo $content->view?></span>
</div>
</a>
</td>
<td class="kboard-list-user"><?php echo $content->member_display?></td>
<td class="kboard-list-date"><?php echo date("Y.m.d", strtotime($content->date))?></td>
<td class="kboard-list-view"><?php echo $content->view?></td>
</tr>
<?php endwhile?>
<?php while($content = $list->hasNext()):?>
<tr>
<td class="kboard-list-uid"><?php echo $list->index()?></td>
<?php if($board->use_category == 'yes'):?>
<?php if($board->initCategory1()):?>
<td class="kboard-list-category1"><?php echo $content->category1?></td>
<?php endif?>
<?php if($board->initCategory2()):?>
<td class="kboard-list-category2"><?php echo $content->category2?></td>
<?php endif?>
<?php endif?>
<td class="kboard-list-title">
<a href="<?php echo $url->set('uid', $content->uid)->set('mod', 'document')->toString()?>">
<div class="kboard-joobong_default-cut-strings">
<?php echo $content->title?>
<?php echo $content->getCommentsCount()?>
<?php if($content->secret):?><img src="<?php echo $skin_path?>/images/icon-lock.png" alt="<?php echo __('Secret', 'kboard')?>"><?php endif?>
<?php if($content->isNew()):?><span class="kboard-joobong_default-new-notify">New</span><?php endif?>
</div>
<div class="kboard-mobile-contents">
<span class="contents-item"><img src="<?php echo $skin_path?>/images/icon-user.png" alt="<?php echo __('Author', 'kboard')?>"> <?php echo $content->member_display?></span>
<span class="contents-item"><img src="<?php echo $skin_path?>/images/icon-date.png" alt="<?php echo __('Date', 'kboard')?>"> <?php echo date("Y.m.d", strtotime($content->date))?></span>
<span class="contents-item"><img src="<?php echo $skin_path?>/images/icon-view.png" alt="<?php echo __('Views', 'kboard')?>"> <?php echo $content->view?></span>
</div>
</a>
</td>
<td class="kboard-list-user"><?php echo $content->member_display?></td>
<td class="kboard-list-date"><?php echo date("Y.m.d", strtotime($content->date))?></td>
<td class="kboard-list-view"><?php echo $content->view?></td>
</tr>
<?php $boardBuilder->builderReply($content->uid)?>
<?php endwhile?>
</tbody>
</table>
</div>
<!-- 리스트 끝 -->
<?php if($board->isWriter()):?>
<!-- 버튼 시작 -->
<div class="kboard-control">
<a href="<?php echo $url->set('mod', 'editor')->toString()?>" class="kboard-joobong_default-button-small"><?php echo __('New', 'kboard')?></a>
</div>
<!-- 버튼 끝 -->
<?php endif?>
<!-- 페이징 시작 -->
<div class="kboard-pagination">
<ul class="kboard-pagination-pages">
<?php echo kboard_pagination($list->page, $list->total, $list->rpp)?>
</ul>
</div>
<!-- 페이징 끝 -->
<!-- 검색폼 시작 -->
<div class="kboard-header">
<form id="kboard-search-form" method="get" action="<?php echo $url->toString()?>">
<div class="kboard-search">
<select name="target">
<option value=""><?php echo __('All', 'kboard')?></option>
<option value="title"<?php if($_GET['target'] == 'title'):?> selected="selected"<?php endif?>><?php echo __('Title', 'kboard')?></option>
<option value="content"<?php if($_GET['target'] == 'content'):?> selected="selected"<?php endif?>><?php echo __('Content', 'kboard')?></option>
<option value="member_display"<?php if($_GET['target'] == 'member_display'):?> selected="selected"<?php endif?>><?php echo __('Author', 'kboard')?></option>
</select>
<input type="text" name="keyword" value="<?php echo $_GET['keyword']?>">
<button type="submit" class="kboard-joobong_default-button-small"><?php echo __('Search', 'kboard')?></button>
</div>
</form>
</div>
<!-- 검색폼 끝 -->
<div class="kboard-joobong_default-poweredby">
<a href="http://www.cosmosfarm.com/products/kboard" onclick="window.open(this.href);return false;" title="<?php echo __('KBoard is the best community software available for WordPress', 'kboard')?>"></a>
</div>
</div>
아래처럼 변경해서 테스트 해보시겠어요?
<form id="kboard-category-form-<?php echo $board->id?>" method="get" action="<?php echo $url->toString()?>">
<?php echo $url->set('pageid', '1')->set('category1', '')->set('category2', '')->set('target', '')->set('keyword', '')->set('mod', 'list')->toInput()?>
<?php if($board->use_category == 'yes'):?>
<div class="kboard-category">
<?php if($board->initCategory1()):?>
<select name="category1" onchange="jQuery('#kboard-category-form-<?php echo $board->id?>').submit();">
<option value=""><?php echo __('All', 'kboard')?></option>
<?php while($board->hasNextCategory()):?>
<option value="<?php echo $board->currentCategory()?>"<?php if($_GET['category1'] == $board->currentCategory()):?> selected="selected"<?php endif?>><?php echo $board->currentCategory()?></option>
<?php endwhile?>
</select>
<?php endif?>
<?php if($board->initCategory2()):?>
<select name="category2" onchange="jQuery('#kboard-category-form-<?php echo $board->id?>').submit();">
<option value=""><?php echo __('All', 'kboard')?></option>
<?php while($board->hasNextCategory()):?>
<option value="<?php echo $board->currentCategory()?>"<?php if($_GET['category2'] == $board->currentCategory()):?> selected="selected"<?php endif?>><?php echo $board->currentCategory()?></option>
<?php endwhile?>
</select>
<?php endif?>
</div>
<?php endif?></form>
제대로 잘 작동하네요! 정말 감사드립니다 ㅠㅠ
제가 몇번이나 귀찮게 해드렸는지 모르겠네요..ㅎㅎ
잘못 작성된 부분 잘 참고하겠습니다. 정말 감사드립니다.