댓글에 대한 답글에 class 지정하는 법 채택완료

아래 댓글에 대한 답변에 class를 지정하고 싶은데 어떻게 코드를 수정해야할까요?

 

(답글은 1단계만 사용합니다.)

 

3076549718_1720556876.1806.png

 

아래 코드에 $cmt_depth가 답글 관련 변수인 거 같은데 답글에 class를 따로 지정하려면 어떻게 해야할지 난감하네요 ㅠㅠ

 

Copy
<!-- 댓글 리스트 -->

<section id="bo_vc">

    <h2 class="bo_vc_tit">댓글목록 <span><?php echo $view['wr_comment']; ?></span></h2>

    <?php

    for ($i=0; $i<count($list); $i++) {

        $comment_id = $list[$i]['wr_id'];

        $cmt_depth = ""; // 댓글단계

        $cmt_depth = strlen($list[$i]['wr_comment_reply']) * 15;

        $str = $list[$i]['content'];

        // if (strstr($list[$i]['wr_option'], "secret"))

            // $str = $str;

        $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);

        $c_reply_href = $comment_common_url.'&amp;c_id='.$comment_id.'&amp;w=c#bo_vc_w';

        $c_edit_href = $comment_common_url.'&amp;c_id='.$comment_id.'&amp;w=cu#bo_vc_w';

        $is_comment_reply_edit = ($list[$i]['is_reply'] || $list[$i]['is_edit'] || $list[$i]['is_del']) ? 1 : 0;

    ?>

    <article id="c_<?php echo $comment_id ?>" <?php if ($cmt_depth) { ?>style="margin-left:<?php echo $cmt_depth ?>px;border-bottom-color:#f8f8f8"<?php } ?>>

        <div class="comment_inner">

            <header>

                <h2><?php echo get_text($list[$i]['wr_name']); ?>님의 댓글<?php if ($cmt_depth) { ?><span class="sound_only">의 댓글</span><?php } ?></h2>

                <?php echo $list[$i]['name'] ?>

                <?php if ($is_ip_view) { ?>

                <span class="sound_only">아이피</span>

                <span class="bo_vc_hdinfo">(<?php echo $list[$i]['ip']; ?>)</span>

                <?php } ?>

                <span class="sound_only">작성일</span>

                <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>

                <?php

                include(G5_SNS_PATH."/view_comment_list.sns.skin.php");

                ?>

                <?php if( $is_comment_reply_edit ){ ?>

                <div class="bo_vl_opt">

                    <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>

                    <ul class="bo_vc_act">

                        <?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 } ?>

                        <?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 } ?>

                        <?php if ($list[$i]['is_del']) { ?><li><a href="<?php echo $list[$i]['del_link']; ?>" onclick="return comment_delete();">삭제</a></li><?php } ?>

                    </ul>

                </div>

                <?php } ?>

                <script>

                $(function() {              

                    // 댓글 옵션창 열기

                    $(".btn_cm_opt").on("click", function(){

                        $(this).parent("div").children(".bo_vc_act").show();

                    });

                           

                    // 댓글 옵션창 닫기

                    $(document).mouseup(function (e){

                        var container = $(".bo_vc_act");

                        if( container.has(e.target).length === 0)

                        container.hide();

                    });

                });

                </script>

            </header>

            <div class="cmt_contents">

                <!-- 댓글 출력 -->

                <p>

                    <?php if (strstr($list[$i]['wr_option'], "secret")) echo "<img src=\"".$board_skin_url."/img/icon_secret.gif\" alt=\"비밀글\">"; ?>

                    <?php echo $str ?>

                </p>

 

                <?php if($list[$i]['is_reply'] || $list[$i]['is_edit'] || $list[$i]['is_del']) {

                    if($w == 'cu') {

                        $sql = " select wr_id, wr_content, mb_id from $write_table where wr_id = '$c_id' and wr_is_comment = '1' ";

                        $cmt = sql_fetch($sql);

                        if (isset($cmt)) {

                            if (!($is_admin || ($member['mb_id'] == $cmt['mb_id'] && $cmt['mb_id']))) {

                                $cmt['wr_content'] = '';

                            }

                            $c_wr_content = $cmt['wr_content'];

                        }

                    }

                ?>

                <?php } ?>

            </div>

                <span id="edit_<?php echo $comment_id ?>"></span><!-- 수정 -->

                <span id="reply_<?php echo $comment_id ?>"></span><!-- 답변 -->

            <input type="hidden" id="secret_comment_<?php echo $comment_id ?>" value="<?php echo strstr($list[$i]['wr_option'],"secret") ?>">

            <textarea id="save_comment_<?php echo $comment_id ?>" style="display:none"><?php echo get_text($list[$i]['content1'], 0) ?></textarea>

        </div>

    </article>

    <?php } ?>

    <?php if ($i == 0) { //댓글이 없다면 ?><p id="bo_vc_empty">등록된 댓글이 없습니다.</p><?php } ?>

 

</section>

 

데모 사이트 : https://demo.sir.kr/gnuboard5/bbs/board.php?bo_table=n_gallery&wr_id=12&device=mobile

 

답글은 "답글보기"를 클릭해야 보이도록 하려고 답글에 class를 지정하려고 하는 건데 힌트라도 주시면 감사합니다 ㅠㅠ

답변 1개

채택된 답변
+20 포인트

 

 

1982090578_1720568450.8002.png

 

 

<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개

네 감사합니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고