댓글에 대한 답글에 class 지정하는 법 채택완료
아래 댓글에 대한 답변에 class를 지정하고 싶은데 어떻게 코드를 수정해야할까요?
(답글은 1단계만 사용합니다.)
http://sir.kr/data/editor/2407/3076549718_1720556876.1806.png" width="100%" />
아래 코드에 $cmt_depth가 답글 관련 변수인 거 같은데 답글에 class를 따로 지정하려면 어떻게 해야할지 난감하네요 ㅠㅠ
</p>
<p><!-- 댓글 리스트 --></p>
<p><section id="bo_vc"></p>
<p> <h2 class="bo_vc_tit">댓글목록 <span><?php echo $view['wr_comment']; ?></span></h2></p>
<p> <?php</p>
<p> for ($i=0; $i<count($list); $i++) {</p>
<p> $comment_id = $list[$i]['wr_id'];</p>
<p> $cmt_depth = ""; // 댓글단계</p>
<p> $cmt_depth = strlen($list[$i]['wr_comment_reply']) * 15;</p>
<p> $str = $list[$i]['content'];</p>
<p> // if (strstr($list[$i]['wr_option'], "secret"))</p>
<p> // $str = $str;</p>
<p> $str = preg_replace("/\[\<a\s.*href\=\"(http|https|ftp|mms)\:\/\/([^[:space:]]+)\.(mp3|wma|wmv|asf|asx|mpg|mpeg)\".*\<\/a\>\]/i", "<script>doc_write(obj_movie('$1://$2.$3'));</script>", $str);</p>
<p> $c_reply_href = $comment_common_url.'&c_id='.$comment_id.'&w=c#bo_vc_w';</p>
<p> $c_edit_href = $comment_common_url.'&c_id='.$comment_id.'&w=cu#bo_vc_w';</p>
<p> $is_comment_reply_edit = ($list[$i]['is_reply'] || $list[$i]['is_edit'] || $list[$i]['is_del']) ? 1 : 0;</p>
<p> ?></p>
<p> <article id="c_<?php echo $comment_id ?>" <?php if ($cmt_depth) { ?>style="margin-left:<?php echo $cmt_depth ?>px;border-bottom-color:#f8f8f8"<?php } ?>></p>
<p> <div class="comment_inner"></p>
<p> <header></p>
<p> <h2><?php echo get_text($list[$i]['wr_name']); ?>님의 댓글<?php if ($cmt_depth) { ?><span class="sound_only">의 댓글</span><?php } ?></h2></p>
<p> <?php echo $list[$i]['name'] ?></p>
<p> <?php if ($is_ip_view) { ?></p>
<p> <span class="sound_only">아이피</span></p>
<p> <span class="bo_vc_hdinfo">(<?php echo $list[$i]['ip']; ?>)</span></p>
<p> <?php } ?></p>
<p> <span class="sound_only">작성일</span></p>
<p> <span class="bo_vc_hdinfo"><i class="fa fa-clock-o" aria-hidden="true"></i> <time datetime="<?php echo date('Y-m-d\TH:i:s+09:00', strtotime($list[$i]['datetime'])) ?>"><?php echo $list[$i]['datetime'] ?></time></span></p>
<p> <?php</p>
<p> include(G5_SNS_PATH."/view_comment_list.sns.skin.php");</p>
<p> ?></p>
<p> <?php if( $is_comment_reply_edit ){ ?></p>
<p> <div class="bo_vl_opt"></p>
<p> <button type="button" class="btn_cm_opt btn_b03 btn"><i class="fa fa-ellipsis-v" aria-hidden="true"></i><span class="sound_only">댓글 옵션</span></button></p>
<p> <ul class="bo_vc_act"></p>
<p> <?php if ($list[$i]['is_reply']) { ?><li><a href="<?php echo $c_reply_href; ?>" onclick="comment_box('<?php echo $comment_id ?>', 'c'); return false;">답변</a></li><?php } ?></p>
<p> <?php if ($list[$i]['is_edit']) { ?><li><a href="<?php echo $c_edit_href; ?>" onclick="comment_box('<?php echo $comment_id ?>', 'cu'); return false;">수정</a></li><?php } ?></p>
<p> <?php if ($list[$i]['is_del']) { ?><li><a href="<?php echo $list[$i]['del_link']; ?>" onclick="return comment_delete();">삭제</a></li><?php } ?></p>
<p> </ul></p>
<p> </div></p>
<p> <?php } ?></p>
<p> <script></p>
<p> $(function() { </p>
<p> // 댓글 옵션창 열기</p>
<p> $(".btn_cm_opt").on("click", function(){</p>
<p> $(this).parent("div").children(".bo_vc_act").show();</p>
<p> });</p>
<p> </p>
<p> // 댓글 옵션창 닫기</p>
<p> $(document).mouseup(function (e){</p>
<p> var container = $(".bo_vc_act");</p>
<p> if( container.has(e.target).length === 0)</p>
<p> container.hide();</p>
<p> });</p>
<p> });</p>
<p> </script></p>
<p> </header></p>
<p> <div class="cmt_contents"></p>
<p> <!-- 댓글 출력 --></p>
<p> <p></p>
<p> <?php if (strstr($list[$i]['wr_option'], "secret")) echo "<img src=\"".$board_skin_url."/img/icon_secret.gif\" alt=\"비밀글\">"; ?></p>
<p> <?php echo $str ?></p>
<p> </p></p>
<p> </p>
<p> <?php if($list[$i]['is_reply'] || $list[$i]['is_edit'] || $list[$i]['is_del']) {</p>
<p> if($w == 'cu') {</p>
<p> $sql = " select wr_id, wr_content, mb_id from $write_table where wr_id = '$c_id' and wr_is_comment = '1' ";</p>
<p> $cmt = sql_fetch($sql);</p>
<p> if (isset($cmt)) {</p>
<p> if (!($is_admin || ($member['mb_id'] == $cmt['mb_id'] && $cmt['mb_id']))) {</p>
<p> $cmt['wr_content'] = '';</p>
<p> }</p>
<p> $c_wr_content = $cmt['wr_content'];</p>
<p> }</p>
<p> }</p>
<p> ?></p>
<p> <?php } ?></p>
<p> </div></p>
<p> <span id="edit_<?php echo $comment_id ?>"></span><!-- 수정 --></p>
<p> <span id="reply_<?php echo $comment_id ?>"></span><!-- 답변 --></p>
<p> <input type="hidden" id="secret_comment_<?php echo $comment_id ?>" value="<?php echo strstr($list[$i]['wr_option'],"secret") ?>"></p>
<p> <textarea id="save_comment_<?php echo $comment_id ?>" style="display:none"><?php echo get_text($list[$i]['content1'], 0) ?></textarea></p>
<p> </div></p>
<p> </article></p>
<p> <?php } ?></p>
<p> <?php if ($i == 0) { //댓글이 없다면 ?><p id="bo_vc_empty">등록된 댓글이 없습니다.</p><?php } ?></p>
<p> </p>
<p></section>
데모 사이트 : https://demo.sir.kr/gnuboard5/bbs/board.php?bo_table=n_gallery&wr_id=12&device=mobile
답글은 "답글보기"를 클릭해야 보이도록 하려고 답글에 class를 지정하려고 하는 건데 힌트라도 주시면 감사합니다 ㅠㅠ
답변 1개

<article id="c_<?php echo $comment_id ?>" <?php if ($cmt_depth) { ?>class="해당클래스" style="margin-left:<?php echo $cmt_depth ?>px;border-bottom-color:#f8f8f8"<?php } ?>>
위 처럼 뎁스가 있다면 대댓글 이므로 클래스 부여 후
cmt_contents 내부 내용을 hidden 하시던가 별도 처리하시면됩니다.
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인