評(píng)論組件

2018-02-24 15:44 更新

評(píng)論組件

上一頁(yè)下一頁(yè)

顯示評(píng)論組件:

{:Comments("posts",$object_id)}

<!--?評(píng)論文章表里的某個(gè)id為$object_id的文章-->

Comments方法說(shuō)明:

參數(shù)1:評(píng)論內(nèi)容所在的表,不帶表前綴的表名稱,如sp_posts應(yīng)該改為“posts”;

參數(shù)2:評(píng)論內(nèi)容的id:

參數(shù)3:數(shù)組,目前支持tpl參數(shù),如array("tpl"=>"comment_custom"),這樣設(shè)置就會(huì)加載模板目錄Comment/coment_custom.html這個(gè)模板。

評(píng)論模板:

默認(rèn)評(píng)論模板文件:Comment/comment.html

<br>
<h3>評(píng)論</h3>
<div?class="comment-area">

    <hr>
    <form?class="form-horizontal?comment-form"?action="{:u('comment/comment/post')}"?method="post">
    ??<div?class="control-group">
        ??<div?class="comment-postbox-wraper">
        ??  <textarea?class="form-control?comment-postbox"?placeholder="Write?your?comment?here"?style="min-height:90px;"??name="content"></textarea>
        ??</div>
    ??</div>
    ??
    ??<div?class="control-group">
    ???     <button?type="submit"?class="btn?pull-right?btn-primary?J_ajax_submit_btn"><i?class="fa?fa-comment-o"></i>?發(fā)表評(píng)論</button>
    ??</div>
    ??
    ??<input?type="hidden"?name="post_table"?value="{:sp_authencode('posts')}"/>
    ??<input?type="hidden"?name="post_id"?value="{$post_id}"/>
    ??<input?type="hidden"?name="to_uid"?value="0"/>
    ??<input?type="hidden"?name="parentid"?value="0"/>
    </form>

    <script?class="comment-tpl"?type="text/html">
        <div?class="comment"?data-username="{$user.user_nicename}"?data-uid="{$user.id}">
        ??<a?class="pull-left"?href="{:U('user/index/index',array('id'=>$user['id']))}">
        ????<img?class="media-object?avatar"?src="{:U('user/public/avatar',array('id'=>$user['id']))}"?class="headicon"/>
        ??</a>
        ??<div?class="comment-body">
        ????<div?class="comment-content"><a?href="{:U('user/index/index',array('id'=>$user['id']))}">{$user.user_nicename}</a>:<span?class="content"></span></div>
        ????<div><span?class="time">剛剛</span>?<a?onclick="comment_reply(this);"?href="javascript:;"><i?class="fa?fa-comment"></i></a></div>
        ??</div>
        ??<div?class="clearfix"></div>
        </div>
    </script>

    <script?class="comment-reply-box-tpl"?type="text/html">
        <div?class="comment-reply-submit">
????????????????????<div?class="comment-reply-box">
????????????????????????<input?type="text"?class="textbox"?placeholder="回復(fù)">
????????????????????</div>
????????????????????<button?class="btn?pull-right"?onclick="comment_submit(this);">回復(fù)</button>
????????????????</div>
    </script>

    <hr>
    <div?class="comments">
    <foreach?name="comments"?item="vo">
    ?   <div?class="comment"?data-id="{$vo.id}"?data-uid="{$vo.uid}"?data-username="{$vo.full_name}"??id="comment{$vo.id}">
        ??<a?class="pull-left"?href="{:U('user/index/index',array('id'=>$vo['uid']))}">
        ????<img?class="media-object?avatar"?src="{:U('user/public/avatar',array('id'=>$vo['uid']))}"?class="headicon"/>
        ??</a>
        ??<div?class="comment-body">
        ????<div?class="comment-content"><a?href="{:U('user/index/index',array('id'=>$vo['uid']))}">{$vo.full_name}</a>:<span>{$vo.content}</span></div>
        ????<div><span?class="time">{:date('m月d日??H:i',strtotime($vo['createtime']))}</span>?<a?onclick="comment_reply(this);"?href="javascript:;"><i?class="fa?fa-comment"></i></a></div>
        ????
        ????<if?condition="!empty($vo['children'])">
        ????    <foreach?name="vo.children"?item="voo">
            ????    <div?class="comment"?data-id="{$voo.id}"?data-uid="{$voo.uid}"?data-username="{$voo.full_name}"?id="comment{$voo.id}">
                    ??<a?class="pull-left"?href="{:U('user/index/index',array('id'=>$voo['uid']))}">
                    ????<img?class="media-object?avatar"?src="{:U('user/public/avatar',array('id'=>$voo['uid']))}"?class="headicon"/>
                    ??</a>
                    ??<div?class="comment-body">
                    ????<div?class="comment-content"><a?href="{:U('user/index/index',array('id'=>$voo['uid']))}">{$voo.full_name}</a>:<span>回復(fù)?<a?href="{:U('user/index/index',array('id'=>$voo['to_uid']))}">{$parent_comments[$voo['parentid']]['full_name']}</a>?{$voo.content}</span></div>
                    ????<div><span?class="time">{:date('m月d日??H:i',strtotime($voo['createtime']))}</span>?<a?onclick="comment_reply(this);"?href="javascript:;"><i?class="fa?fa-comment"></i></a></div>
                    ??</div>
                    ??<div?class="clearfix"></div>
                    </div>
        ????    </foreach>
        ????
        ????</if>
        ????
        ????
        ??</div>
        ??<div?class="clearfix"></div>
        </div>
    </foreach>
    </div>

</div>

上一頁(yè)下一頁(yè)

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)