https://www.clien.net/service/group/allinfo
공지사항 바로 아래에
'광고' 게시글을 작성하려면 어디를 수정해야 할까요?
관리자가 글 작성시 '공지사항' 체크 켜고, 글작성 같이,
관리자가 '광고' 체크 켜고 글작성하면
공지사항 바로 아래 고정형 게시글로 나타나게 하려고 합니다. 공지사항 같이요.
안녕하세요~^^
FTP로 접속해서 스킨 파일을 수정해주세요.
저희는 default 스킨에서 테스트해봤습니다.
1. /wp-content/plugins/kboard/skin/사용중인스킨/editor.php 파일에 아래 코드를 추가해주세요.
<div class="kboard-attr-row">
<label class="attr-name" for="kboard_option_advertising">광고</label>
<div class="attr-value">
<label>
<!-- 아래 히든(hidden) 필드의 값은 체크박스가 체크되지 않았을 때 저장할 기본값입니다. -->
<input type="hidden" name="kboard_option_advertising" value="">
<input type="checkbox" name="kboard_option_advertising" value="1"<?php if($content->option->advertising):?> checked<?php endif?>>
광고
</label>
</div>
</div>
2. /wp-content/plugins/kboard/skin/사용중인스킨/list.php 파일에 아래 코드를 추가해주세요.
리스트에서 공지사항과 일반 글 출력 사이에 코드를 넣어주시면 되겠습니다.
<?php
$advertising_list = new KBContentList($board->id);
$advertising_list->addSearchOption('advertising', '1');
$advertising_list->getList();
while($content = $advertising_list->hasNext()):?>
<tr class="kboard-list-notice<?php if($content->uid == kboard_uid()):?> kboard-list-selected<?php endif?>">
<td class="kboard-list-uid">광고</td>
<td class="kboard-list-title">
<a href="<?php echo $url->set('uid', $content->uid)->set('mod', 'document')->toString()?>">
<div class="kboard-default-cut-strings">
<?php if($content->isNew()):?><span class="kboard-default-new-notify">New</span><?php endif?>
<?php if($content->secret):?><img src="<?php echo $skin_path?>/images/icon-lock.png" alt="<?php echo __('Secret', 'kboard')?>"><?php endif?>
<?php echo $content->title?>
<span class="kboard-comments-count"><?php echo $content->getCommentsCount()?></span>
</div>
</a>
<div class="kboard-mobile-contents">
<span class="contents-item kboard-user"><?php echo apply_filters('kboard_user_display', $content->member_display, $content->member_uid, $content->member_display, 'kboard', $boardBuilder)?></span>
<span class="contents-separator kboard-date">|</span>
<span class="contents-item kboard-date"><?php echo $content->getDate()?></span>
<span class="contents-separator kboard-vote">|</span>
<span class="contents-item kboard-vote"><?php echo __('Votes', 'kboard')?> <?php echo $content->vote?></span>
<span class="contents-separator kboard-view">|</span>
<span class="contents-item kboard-view"><?php echo __('Views', 'kboard')?> <?php echo $content->view?></span>
</div>
</td>
<td class="kboard-list-user"><?php echo apply_filters('kboard_user_display', $content->member_display, $content->member_uid, $content->member_display, 'kboard', $boardBuilder)?></td>
<td class="kboard-list-date"><?php echo $content->getDate()?></td>
<td class="kboard-list-vote"><?php echo $content->vote?></td>
<td class="kboard-list-view"><?php echo $content->view?></td>
</tr>
<?php endwhile?>
3. 테마의 functions.php 파일에 아래 코드를 추가해주세요.
아래 코드가 추가되어야 일반 글 리스트에서 광고로 선택된 게시글이 나오지 않습니다.
add_filter('kboard_list_where', 'my_where_exclusion_advertising', 10, 3);
function my_where_exclusion_advertising($where, $board_id, $content_list){
global $wpdb;
if(!$content_list->search_option){
$where .= " AND `{$wpdb->prefix}kboard_board_content`.`uid` NOT IN (SELECT `content_uid` FROM `{$wpdb->prefix}kboard_board_option` WHERE `option_key`='advertising')";
}
return $where;
}
테스트 하는데 시간이 많이 걸렸네요 ㅎㅎ;;
고맙습니다.
잘 됩니다.
$board->isAdmin() 코드로 관리자인지 아닌지 체크할 수 있습니다.
아래 처럼 해보시겠어요?
<?php if($board->isAdmin()):?>
<div class="kboard-attr-row">
<label class="attr-name" for="kboard_option_advertising">광고</label>
<div class="attr-value">
<label>
<!-- 아래 히든(hidden) 필드의 값은 체크박스가 체크되지 않았을 때 저장할 기본값입니다. -->
<input type="hidden" name="kboard_option_advertising" value="">
<input type="checkbox" name="kboard_option_advertising" value="1"<?php if($content->option->advertising):?> checked<?php endif?>>
광고
</label>
</div>
</div>
<?php endif?>
고맙습니다.
https://imgur.com/a/qqx67Yv
https://imgur.com/a/XdfeFGt
공지사항과 광고가 분리되서 잘 나옵니다.
https://imgur.com/a/PmLLhcl
광고 체크 버튼을 공지사항 체크 버튼 같이 어드민(관리자)만 보여주려면 어떻게 해야 하나요?
안녕하세요.
list.php 파일 쪽에 문제가 있는 듯합니다.
아래처럼 적용해보시겠어요?
<!-- 리스트 시작 -->
<div class="kboard-list">
<table>
<thead>
<tr>
<td class="kboard-list-uid"><?php echo __('Number', 'kboard')?></td>
<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-vote"><?php echo __('Votes', '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<?php if($content->uid == kboard_uid()):?> kboard-list-selected<?php endif?>">
<td class="kboard-list-uid"><?php echo __('Notice', 'kboard')?></td>
<td class="kboard-list-title">
<a href="<?php echo $url->set('uid', $content->uid)->set('mod', 'document')->toString()?>">
<div class="kboard-default-cut-strings">
<?php if($content->isNew()):?><span class="kboard-default-new-notify">New</span><?php endif?>
<?php if($content->secret):?><img src="<?php echo $skin_path?>/images/icon-lock.png" alt="<?php echo __('Secret', 'kboard')?>"><?php endif?>
<?php echo $content->title?>
<span class="kboard-comments-count"><?php echo $content->getCommentsCount()?></span>
</div>
</a>
<div class="kboard-mobile-contents">
<span class="contents-item kboard-user"><?php echo apply_filters('kboard_user_display', $content->member_display, $content->member_uid, $content->member_display, 'kboard', $boardBuilder)?></span>
<span class="contents-separator kboard-date">|</span>
<span class="contents-item kboard-date"><?php echo $content->getDate()?></span>
<span class="contents-separator kboard-vote">|</span>
<span class="contents-item kboard-vote"><?php echo __('Votes', 'kboard')?> <?php echo $content->vote?></span>
<span class="contents-separator kboard-view">|</span>
<span class="contents-item kboard-view"><?php echo __('Views', 'kboard')?> <?php echo $content->view?></span>
</div>
</td>
<td class="kboard-list-user"><?php echo apply_filters('kboard_user_display', $content->member_display, $content->member_uid, $content->member_display, 'kboard', $boardBuilder)?></td>
<td class="kboard-list-date"><?php echo $content->getDate()?></td>
<td class="kboard-list-vote"><?php echo $content->vote?></td>
<td class="kboard-list-view"><?php echo $content->view?></td>
</tr>
<?php endwhile?>
<?php
$advertising_list = new KBContentList($board->id);
$advertising_list->addSearchOption('advertising', '1');
$advertising_list->getList();
while($content = $advertising_list->hasNext()):?>
<tr class="kboard-list-notice<?php if($content->uid == kboard_uid()):?> kboard-list-selected<?php endif?>">
<td class="kboard-list-uid">광고</td>
<td class="kboard-list-title">
<a href="<?php echo $url->set('uid', $content->uid)->set('mod', 'document')->toString()?>">
<div class="kboard-default-cut-strings">
<?php if($content->isNew()):?><span class="kboard-default-new-notify">New</span><?php endif?>
<?php if($content->secret):?><img src="<?php echo $skin_path?>/images/icon-lock.png" alt="<?php echo __('Secret', 'kboard')?>"><?php endif?>
<?php echo $content->title?>
<span class="kboard-comments-count"><?php echo $content->getCommentsCount()?></span>
</div>
</a>
<div class="kboard-mobile-contents">
<span class="contents-item kboard-user"><?php echo apply_filters('kboard_user_display', $content->member_display, $content->member_uid, $content->member_display, 'kboard', $boardBuilder)?></span>
<span class="contents-separator kboard-date">|</span>
<span class="contents-item kboard-date"><?php echo $content->getDate()?></span>
<span class="contents-separator kboard-vote">|</span>
<span class="contents-item kboard-vote"><?php echo __('Votes', 'kboard')?> <?php echo $content->vote?></span>
<span class="contents-separator kboard-view">|</span>
<span class="contents-item kboard-view"><?php echo __('Views', 'kboard')?> <?php echo $content->view?></span>
</div>
</td>
<td class="kboard-list-user"><?php echo apply_filters('kboard_user_display', $content->member_display, $content->member_uid, $content->member_display, 'kboard', $boardBuilder)?></td>
<td class="kboard-list-date"><?php echo $content->getDate()?></td>
<td class="kboard-list-vote"><?php echo $content->vote?></td>
<td class="kboard-list-view"><?php echo $content->view?></td>
</tr>
<?php endwhile?>
<?php while($content = $list->hasNext()):?>
<tr class="<?php if($content->uid == kboard_uid()):?>kboard-list-selected<?php endif?>">
<td class="kboard-list-uid"><?php echo $list->index()?></td>
<td class="kboard-list-title">
<a href="<?php echo $url->set('uid', $content->uid)->set('mod', 'document')->toString()?>">
<div class="kboard-default-cut-strings">
<?php if($content->isNew()):?><span class="kboard-default-new-notify">New</span><?php endif?>
<?php if($content->secret):?><img src="<?php echo $skin_path?>/images/icon-lock.png" alt="<?php echo __('Secret', 'kboard')?>"><?php endif?>
<?php echo $content->title?>
<span class="kboard-comments-count"><?php echo $content->getCommentsCount()?></span>
</div>
</a>
<div class="kboard-mobile-contents">
<span class="contents-item kboard-user"><?php echo apply_filters('kboard_user_display', $content->member_display, $content->member_uid, $content->member_display, 'kboard', $boardBuilder)?></span>
<span class="contents-separator kboard-date">|</span>
<span class="contents-item kboard-date"><?php echo $content->getDate()?></span>
<span class="contents-separator kboard-vote">|</span>
<span class="contents-item kboard-vote"><?php echo __('Votes', 'kboard')?> <?php echo $content->vote?></span>
<span class="contents-separator kboard-view">|</span>
<span class="contents-item kboard-view"><?php echo __('Views', 'kboard')?> <?php echo $content->view?></span>
</div>
</td>
<td class="kboard-list-user"><?php echo apply_filters('kboard_user_display', $content->member_display, $content->member_uid, $content->member_display, 'kboard', $boardBuilder)?></td>
<td class="kboard-list-date"><?php echo $content->getDate()?></td>
<td class="kboard-list-vote"><?php echo $content->vote?></td>
<td class="kboard-list-view"><?php echo $content->view?></td>
</tr>
<?php $boardBuilder->builderReply($content->uid)?>
<?php endwhile?>
</tbody>
</table>
</div>
<!-- 리스트 끝 -->
추가로 코드를 올리실 때 에디터의 "코드 스니펫 삽입" 기능으로 삽입해주세요.
그렇지 않으면 코드가 이상해져서 에러 나는 코드로 바뀌거나,
질의응답 시 의사소통에 오해와 문제가 생길 수도 있기 때문입니다.
고맙습니다.
https://imgur.com/a/EgTpXWU
일반회원 로그인 후 글쓰기 해봤는데요, 광고 체크 표시가 나옵니다ㅠㅠ
위 스샷에는 공지사항 체크가 안나오고 있어서 정상입니다. 공지사항 같이 광고 체크가 안나와야 하거든요.
editor.php도 올립니다.
<div class="kboard-attr-row">
<div class="attr-name"><?php echo __('Options', 'kboard')?></div>
<div class="attr-value">
<label class="attr-value-option"><input type="checkbox" name="secret" value="true" onchange="kboard_toggle_password_field(this)"<?php if($content->secret):?> checked<?php endif?>> <?php echo __('Secret', 'kboard')?></label>
<?php if($board->isAdmin()):?>
<label class="attr-value-option"><input type="checkbox" name="notice" value="true"<?php if($content->notice):?> checked<?php endif?>> <?php echo __('Notice', 'kboard')?></label>
<?php endif?>
</div>
</div>
<!--광고 시작-->
<div class="kboard-attr-row">
<label class="attr-name" for="kboard_option_advertising">광고</label>
<div class="attr-value">
<label>
<!-- 아래 히든(hidden) 필드의 값은 체크박스가 체크되지 않았을 때 저장할 기본값입니다. -->
<input type="hidden" name="kboard_option_advertising" value="">
<input type="checkbox" name="kboard_option_advertising" value="1"<?php if($content->option->advertising):?> checked<?php endif?>>
광고
</label>
</div>
</div>
<!--광고 종료-->
<?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?>
리스트 부분이 이상해서 코드 추가한 부분 올립니다.
list.php 파일의 리스트 부분에 공지 바로 아래에 추가하였습니다.
추가한 부분이 광고시작, 광고종료 부분입니다.
<!-- 리스트 시작 -->
<div class="kboard-list">
<table>
<thead>
<tr>
<td class="kboard-list-uid"><?php echo __('Number', 'kboard')?></td>
<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-vote"><?php echo __('Votes', '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<?php if($content->uid == kboard_uid()):?> kboard-list-selected<?php endif?>">
<td class="kboard-list-uid">공지</td>
<td class="kboard-list-title">
<a href="<?php echo $url->set('uid', $content->uid)->set('mod', 'document')->toString()?>">
<div class="kboard-default-cut-strings">
<?php if($content->isNew()):?><span class="kboard-default-new-notify">N</span><?php endif?>
<?php if($content->secret):?><img src="<?php echo $skin_path?>/images/icon-lock.png" alt="<?php echo __('Secret', 'kboard')?>"><?php endif?>
<?php echo $content->title?>
<?php $media = new KBContentMedia();
$media->content_uid = $content->uid;
if($media->getList()){
$src = "{$skin_path}/images/icon-attach.png";
echo '<img src="' . $src . '" alt="이미지첨부">';
}
?>
<span class="kboard-comments-count"><?php echo $content->getCommentsCount()?></span>
</div>
</a>
<div class="kboard-mobile-contents">
<span class="contents-item kboard-user"><?php echo apply_filters('kboard_user_display', $content->member_display, $content->member_uid, $content->member_display, 'kboard', $boardBuilder)?></span>
<span class="contents-separator kboard-date">|</span>
<span class="contents-item kboard-date"><?php echo $content->getDate()?></span>
<span class="contents-separator kboard-vote">|</span>
<span class="contents-item kboard-vote"><?php echo __('Votes', 'kboard')?> <?php echo $content->vote?></span>
<span class="contents-separator kboard-view">|</span>
<span class="contents-item kboard-view"><?php echo __('Views', 'kboard')?> <?php echo $content->view?></span>
</div>
</td>
<td class="kboard-list-user"><?php echo apply_filters('kboard_user_display', $content->member_display, $content->member_uid, $content->member_display, 'kboard', $boardBuilder)?></td>
<td class="kboard-list-date"><?php echo $content->getDate()?></td>
<td class="kboard-list-vote"><?php echo $content->vote?></td>
<td class="kboard-list-view"><?php echo $content->view?></td>
</tr>
<!-- 광고시작 -->
<?php
$advertising_list = new KBContentList($board->id);
$advertising_list->addSearchOption('advertising', '1');
$advertising_list->getList();
while($content = $advertising_list->hasNext()):?>
<tr class="kboard-list-notice<?php if($content->uid == kboard_uid()):?> kboard-list-selected<?php endif?>">
<td class="kboard-list-uid">광고</td>
<td class="kboard-list-title">
<a href="<?php echo $url->set('uid', $content->uid)->set('mod', 'document')->toString()?>">
<div class="kboard-default-cut-strings">
<?php if($content->isNew()):?><span class="kboard-default-new-notify">N</span><?php endif?>
<?php if($content->secret):?><img src="<?php echo $skin_path?>/images/icon-lock.png" alt="<?php echo __('Secret', 'kboard')?>"><?php endif?>
<?php echo $content->title?>
<span class="kboard-comments-count"><?php echo $content->getCommentsCount()?></span>
</div>
</a>
<div class="kboard-mobile-contents">
<span class="contents-item kboard-user"><?php echo apply_filters('kboard_user_display', $content->member_display, $content->member_uid, $content->member_display, 'kboard', $boardBuilder)?></span>
<span class="contents-separator kboard-date">|</span>
<span class="contents-item kboard-date"><?php echo $content->getDate()?></span>
<span class="contents-separator kboard-vote">|</span>
<span class="contents-item kboard-vote"><?php echo __('Votes', 'kboard')?> <?php echo $content->vote?></span>
<span class="contents-separator kboard-view">|</span>
<span class="contents-item kboard-view"><?php echo __('Views', 'kboard')?> <?php echo $content->view?></span>
</div>
</td>
<td class="kboard-list-user"><?php echo apply_filters('kboard_user_display', $content->member_display, $content->member_uid, $content->member_display, 'kboard', $boardBuilder)?></td>
<td class="kboard-list-date"><?php echo $content->getDate()?></td>
<td class="kboard-list-vote"><?php echo $content->vote?></td>
<td class="kboard-list-view"><?php echo $content->view?></td>
</tr>
<?php endwhile?>
<!--광고종료-->
<?php endwhile?>
<?php while($content = $list->hasNext()):?>
<tr class="<?php if($content->uid == kboard_uid()):?>kboard-list-selected<?php endif?>">
<td class="kboard-list-uid"><?php echo $list->index()?></td>
<td class="kboard-list-title">
<a href="<?php echo $url->set('uid', $content->uid)->set('mod', 'document')->toString()?>">
<div class="kboard-default-cut-strings">
<?php if($content->isNew()):?><span class="kboard-default-new-notify">N</span><?php endif?>
<?php if($content->secret):?><img src="<?php echo $skin_path?>/images/icon-lock.png" alt="<?php echo __('Secret', 'kboard')?>"><?php endif?>
<?php $media = new KBContentMedia();
$media->content_uid = $content->uid;
if($media->getList()){
$src = "{$skin_path}/images/icon-attach.png";
echo '<img src="' . $src . '" alt="이미지첨부">';
}
?>
<?php echo $content->title?>
<span class="kboard-comments-count"><?php echo $content->getCommentsCount()?></span>
</div>
</a>
<div class="kboard-mobile-contents">
<span class="contents-item kboard-user"><?php echo apply_filters('kboard_user_display', $content->member_display, $content->member_uid, $content->member_display, 'kboard', $boardBuilder)?></span>
<span class="contents-separator kboard-date">|</span>
<span class="contents-item kboard-date"><?php echo $content->getDate()?></span>
<span class="contents-separator kboard-vote">|</span>
<span class="contents-item kboard-vote"><?php echo __('Votes', 'kboard')?> <?php echo $content->vote?></span>
<span class="contents-separator kboard-view">|</span>
<span class="contents-item kboard-view"><?php echo __('Views', 'kboard')?> <?php echo $content->view?></span>
</div>
</td>
<td class="kboard-list-user"><?php echo apply_filters('kboard_user_display', $content->member_display, $content->member_uid, $content->member_display, 'kboard', $boardBuilder)?></td>
<td class="kboard-list-date"><?php echo $content->getDate()?></td>
<td class="kboard-list-vote"><?php echo $content->vote?></td>
<td class="kboard-list-view"><?php echo $content->view?></td>
</tr>
<?php $boardBuilder->builderReply($content->uid)?>
<?php endwhile?>
</tbody>
</table>
</div>
<!-- 리스트 끝 -->
https://imgur.com/a/xP5w8iP
1. 광고만 체크해봤는데도, 여러개가 나옵니다ㅠㅠ
https://imgur.com/a/atF3QoC
2. 3번째로 새로운 문제가 있는데요, 공지를 작성하면 광고까지 따라서 나옵니다.
'비밀글과 공지사항 등록' 이란 공지를 새로 등록했는데
바로 아래 광고가 자동으로 생겨납니다ㅠㅠ
광고글 등록하실 때 공지사항 체크를 해주셨나요?
광고글 혹은 공지사항 둘 중 하나만 체크를 해주셔야 할 듯합니다.
광고글은 공지사항이 아니거든요.
아니면 스킨 파일에 코드 입력을 잘못해준 것 같습니다.
비회원으로 테스트할 수 있는 페이지 주소 알려주시겠어요?
고맙습니다.
광고글 작성과 등록이 잘 되는데요.
1. 공지사항 개수만큼 똑같이 나옵니다ㅠㅠ
공지사항을 2개인 상태에서 광고글 1개 작성했는데,
1개의 광고글이 공지사항이랑 똑같이 2개가 나왔어요.
2. 공지사항이 몇 개이든 공지사항 바로 아래에 나와야 하는데,
공지사항
광고
공지사항
광고
.
.
.
공지사항 사이사이에 나옵니다 ㅠㅠ
잘됩니다. 감사드립니다.