게시판 목록에서 자신이 보고 있는 곳 다르게 표시하기기
본문
수고하십니다.
일전에 질문을 드렸는데
잘 안되어서 질문을 다시 드립니다.
게시판에서 자신이 읽고 있는 목록을 다르게 표시하고 싶습니다.
첨부 이미지 처럼 읽고 있는 칸은 다른 색상으로 표시가 되는 거죠.
리빌더를 사용중인데요.
그누보드 기본 보드와 좀 다른가 봅니다.
답변은 아래와 같이 받았습니다.
lisk.skin.php
// 현재 보고 있는 게시글 ID 가져오기
$current_wr_id = isset($_GET['wr_id']) ? $_GET['wr_id'] : '';
// 목록 출력 부분
for ($i=0; $i<count($list); $i++) {
// 현재 게시글인지 확인
$is_current = ($current_wr_id && $list[$i]['wr_id'] == $current_wr_id) ? 'current-post' : '';
echo '<tr class="'.$is_current.'">';
// 게시글 내용 출력
echo '</tr>';
}
css
/* 현재 보고 있는 게시글 강조 */
tr.current-post {
background-color: #e8f4ff !important;
border-left: 3px solid #4a90e2;
}
tr.current-post td {
font-weight: 500;
}
/* 호버 효과와 구분 */
tr.current-post:hover {
background-color: #d4e9ff !important;
}
리빌더 list.php 에는
아래와 같은 코드인데 어떻게 수정을 해야 할 지 모르겠습니다.
<?php
for ($i=0; $i<count($list); $i++) {
$sec_icon = '';
if (strstr($list[$i]['wr_option'], 'secret')) {
$sec_txt = '<span style="opacity:0.6">작성자 및 관리자 외 열람할 수 없습니다.<br>비밀글 기능으로 보호된 글입니다.</span>';
$sec_icon = '<img src="'.$board_skin_url.'/img/ico_sec.svg"> ';
}
?>
<tr class="<?php if ($list[$i]['is_notice']) echo "bo_notice"; ?>">
<td class="rb-board-no font-B" nowrap>
<?php if ($is_checkbox) { ?>
<input type="checkbox" name="chk_wr_id[]" value="<?php echo $list[$i]['wr_id'] ?>" id="chk_wr_id_<?php echo $i ?>" class="">
<label for="chk_wr_id_<?php echo $i ?>"></label>
<?php } else { ?>
<?php
if($list[$i]['is_notice']) {
echo '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-volume-2"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"></polygon><path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"></path></svg>';
} else if (strstr($list[$i]['wr_option'], 'secret')) {
echo $sec_icon;
} else if ($list[$i]['icon_new']) {
echo "<span class=\"lb_ico_new font-R\">New</span>";
} else {
echo number_format($list[$i]['num']);
}
?>
<?php } ?>
</td>
조언 좀 부탁드립니다.
감사합니다.
.
답변 1
안녕하세요...
오랜만에 답변 드리네요
사용하시는게 통합인지 알수 없지만, 대부분 비슷한 코드가 있어요
위에 알려주신 코드 기준으로
<tr class="<?php if ($list[$i]['is_notice']) echo "bo_notice"; ?>">
이 코드를 아래처럼 변경 해주세요
<tr class="<?php
if ($list[$i]['is_notice']) echo 'bo_notice';
if ($wr_id == $list[$i]['wr_id']) echo ( ($list[$i]['is_notice']) ? ' ' : '') . 'bo_current';
?>">
그리고 나서 style 을 .bo_current 를 주시면 됩니다.
예)
<style>
.bo_current {
background-color: #f9fafb;
}
</style>
그럼 아래처럼 표시가 됩니다.
