그누보드 게시판 공지사항 따로 추출
본문
그누보드 공지를 체크하면
게시판영역밖에 아예 따로 빼고 싶어서요
<?php if ($list[$i]['is_notice']) { ?>
<div class="tbl_head01 tbl_wrap">
<table>
<caption><?php echo $board['bo_subject'] ?> 목록</caption>
<thead>
<tr>
<?php if ($is_checkbox) { ?>
<th scope="col">
<label for="chkall" class="sound_only">현재 페이지 게시물 전체</label>
<input type="checkbox" id="chkall" onclick="if (this.checked) all_checked(true); else all_checked(false);">
</th>
<?php } ?>
<th scope="col">번호</th>
<th scope="col">제목</th>
<th scope="col">글쓴이</th>
<th scope="col"><?php echo subject_sort_link('wr_hit', $qstr2, 1) ?>조회 <i class="fa fa-sort" aria-hidden="true"></i></a></th>
<?php if ($is_good) { ?><th scope="col"><?php echo subject_sort_link('wr_good', $qstr2, 1) ?>추천 <i class="fa fa-sort" aria-hidden="true"></i></a></th><?php } ?>
<?php if ($is_nogood) { ?><th scope="col"><?php echo subject_sort_link('wr_nogood', $qstr2, 1) ?>비추천 <i class="fa fa-sort" aria-hidden="true"></i></a></th><?php } ?>
<th scope="col"><?php echo subject_sort_link('wr_datetime', $qstr2, 1) ?>날짜 <i class="fa fa-sort" aria-hidden="true"></i></a></th>
</tr>
</thead>
<tbody>
<?php
for ($i=0; $i<count($list); $i++) {
?>
<tr class="<?php if ($list[$i]['is_notice']) echo "bo_notice"; ?>">
<?php if ($is_checkbox) { ?>
<td class="td_chk">
<label for="chk_wr_id_<?php echo $i ?>" class="sound_only"><?php echo $list[$i]['subject'] ?></label>
<input type="checkbox" name="chk_wr_id[]" value="<?php echo $list[$i]['wr_id'] ?>" id="chk_wr_id_<?php echo $i ?>">
</td>
<?php } ?>
<td class="td_num2">
<?php
if ($list[$i]['is_notice']) // 공지사항
echo '<strong class="notice_icon"><i class="fa fa-bullhorn" aria-hidden="true"></i><span class="sound_only">공지</span></strong>';
else if ($wr_id == $list[$i]['wr_id'])
echo "<span class=\"bo_current\">열람중</span>";
else
echo $list[$i]['num'];
?>
</td>
<td class="td_subject" style="padding-left:<?php echo $list[$i]['reply'] ? (strlen($list[$i]['wr_reply'])*10) : '0'; ?>px">
<?php
if ($is_category && $list[$i]['ca_name']) {
?>
<a href="<?php echo $list[$i]['ca_name_href'] ?>" class="bo_cate_link"><?php echo $list[$i]['ca_name'] ?></a>
<?php } ?>
<div class="bo_tit">
<a href="<?php echo $list[$i]['href'] ?>">
<?php echo $list[$i]['icon_reply'] ?>
<?php
if (isset($list[$i]['icon_secret'])) echo rtrim($list[$i]['icon_secret']);
?>
<?php echo $list[$i]['subject'] ?>
</a>
<?php
// if ($list[$i]['link']['count']) { echo '['.$list[$i]['link']['count']}.']'; }
// if ($list[$i]['file']['count']) { echo '<'.$list[$i]['file']['count'].'>'; }
if (isset($list[$i]['icon_file'])) echo rtrim($list[$i]['icon_file']);
if (isset($list[$i]['icon_link'])) echo rtrim($list[$i]['icon_link']);
if (isset($list[$i]['icon_new'])) echo rtrim($list[$i]['icon_new']);
if (isset($list[$i]['icon_hot'])) echo rtrim($list[$i]['icon_hot']);
?>
<?php if ($list[$i]['comment_cnt']) { ?><span class="sound_only">댓글</span><span class="cnt_cmt">+ <?php echo $list[$i]['wr_comment']; ?></span><span class="sound_only">개</span><?php } ?>
</div>
</td>
<td class="td_name sv_use"><?php echo $list[$i]['name'] ?></td>
<td class="td_num"><?php echo $list[$i]['wr_hit'] ?></td>
<?php if ($is_good) { ?><td class="td_num"><?php echo $list[$i]['wr_good'] ?></td><?php } ?>
<?php if ($is_nogood) { ?><td class="td_num"><?php echo $list[$i]['wr_nogood'] ?></td><?php } ?>
<td class="td_datetime"><?php echo $list[$i]['datetime2'] ?></td>
</tr>
<?php } ?>
<?php if (count($list) == 0) { echo '<tr><td colspan="'.$colspan.'" class="empty_table">게시물이 없습니다.</td></tr>'; } ?>
</tbody>
</table>
</div>
<?php } else {?>
<div class="tbl_head01 tbl_wrap">
<table>
<caption><?php echo $board['bo_subject'] ?> 목록</caption>
<thead>
<tr>
<?php if ($is_checkbox) { ?>
<th scope="col">
<label for="chkall" class="sound_only">현재 페이지 게시물 전체</label>
<input type="checkbox" id="chkall" onclick="if (this.checked) all_checked(true); else all_checked(false);">
</th>
<?php } ?>
<th scope="col">번호</th>
<th scope="col">제목</th>
<th scope="col">글쓴이</th>
<th scope="col"><?php echo subject_sort_link('wr_hit', $qstr2, 1) ?>조회 <i class="fa fa-sort" aria-hidden="true"></i></a></th>
<?php if ($is_good) { ?><th scope="col"><?php echo subject_sort_link('wr_good', $qstr2, 1) ?>추천 <i class="fa fa-sort" aria-hidden="true"></i></a></th><?php } ?>
<?php if ($is_nogood) { ?><th scope="col"><?php echo subject_sort_link('wr_nogood', $qstr2, 1) ?>비추천 <i class="fa fa-sort" aria-hidden="true"></i></a></th><?php } ?>
<th scope="col"><?php echo subject_sort_link('wr_datetime', $qstr2, 1) ?>날짜 <i class="fa fa-sort" aria-hidden="true"></i></a></th>
</tr>
</thead>
<tbody>
<?php
for ($i=0; $i<count($list); $i++) {
?>
<tr class="<?php if ($list[$i]['is_notice']) echo "bo_notice"; ?>">
<?php if ($is_checkbox) { ?>
<td class="td_chk">
<label for="chk_wr_id_<?php echo $i ?>" class="sound_only"><?php echo $list[$i]['subject'] ?></label>
<input type="checkbox" name="chk_wr_id[]" value="<?php echo $list[$i]['wr_id'] ?>" id="chk_wr_id_<?php echo $i ?>">
</td>
<?php } ?>
<td class="td_num2">
<?php
if ($list[$i]['is_notice']) // 공지사항
echo '<strong class="notice_icon"><i class="fa fa-bullhorn" aria-hidden="true"></i><span class="sound_only">공지</span></strong>';
else if ($wr_id == $list[$i]['wr_id'])
echo "<span class=\"bo_current\">열람중</span>";
else
echo $list[$i]['num'];
?>
</td>
<td class="td_subject" style="padding-left:<?php echo $list[$i]['reply'] ? (strlen($list[$i]['wr_reply'])*10) : '0'; ?>px">
<?php
if ($is_category && $list[$i]['ca_name']) {
?>
<a href="<?php echo $list[$i]['ca_name_href'] ?>" class="bo_cate_link"><?php echo $list[$i]['ca_name'] ?></a>
<?php } ?>
<div class="bo_tit">
<a href="<?php echo $list[$i]['href'] ?>">
<?php echo $list[$i]['icon_reply'] ?>
<?php
if (isset($list[$i]['icon_secret'])) echo rtrim($list[$i]['icon_secret']);
?>
<?php echo $list[$i]['subject'] ?>
</a>
<?php
// if ($list[$i]['link']['count']) { echo '['.$list[$i]['link']['count']}.']'; }
// if ($list[$i]['file']['count']) { echo '<'.$list[$i]['file']['count'].'>'; }
if (isset($list[$i]['icon_file'])) echo rtrim($list[$i]['icon_file']);
if (isset($list[$i]['icon_link'])) echo rtrim($list[$i]['icon_link']);
if (isset($list[$i]['icon_new'])) echo rtrim($list[$i]['icon_new']);
if (isset($list[$i]['icon_hot'])) echo rtrim($list[$i]['icon_hot']);
?>
<?php if ($list[$i]['comment_cnt']) { ?><span class="sound_only">댓글</span><span class="cnt_cmt">+ <?php echo $list[$i]['wr_comment']; ?></span><span class="sound_only">개</span><?php } ?>
</div>
</td>
<td class="td_name sv_use"><?php echo $list[$i]['name'] ?></td>
<td class="td_num"><?php echo $list[$i]['wr_hit'] ?></td>
<?php if ($is_good) { ?><td class="td_num"><?php echo $list[$i]['wr_good'] ?></td><?php } ?>
<?php if ($is_nogood) { ?><td class="td_num"><?php echo $list[$i]['wr_nogood'] ?></td><?php } ?>
<td class="td_datetime"><?php echo $list[$i]['datetime2'] ?></td>
</tr>
<?php } ?>
<?php if (count($list) == 0) { echo '<tr><td colspan="'.$colspan.'" class="empty_table">게시물이 없습니다.</td></tr>'; } ?>
</tbody>
</table>
</div>
<?php }?>
이런식으로 썼는데, 따로 영역이 분리되서 안나와서요...
분리해서 나오고 싶은데 어떻게 해야하나요?
!-->답변 2
<?php
$notice_tmp = 0;
for ($i=0; $i<count($list); $i++) {
if($notice_tmp && !$list[$i]['is_notice']) {
?>
이 부분에.. 공지와 게시물 사이의 태그 입력
<?php
$notice_tmp = $list[$i]['is_notice'];
?>
<tr class="<?php if ($list[$i]['is_notice']) echo "bo_notice"; ?>">
원 로직을 단순화하면,
for ($i = 0; $i < count($list); $i++) {
if ($list[$i]['is_notice']) // 공지글이면
~
else // 아니면
~
}
입니다.
=>
// 공지글만 출력
for ($i = 0; $i < count($list); $i++) {
if (!$list[$i]['is_notice'])
continue; // 공지글이 아니면 건너뛰기
~
}
// 일반글만 출력
for ($i = 0; $i < count($list); $i++) {
if ($list[$i]['is_notice'])
continue; // 공지글이면 건너뛰기
~
}