Share lại code shoutbox có bình luận phiên bản 1.0 cho anh em nào cần. Code này được share với mục đích làm tài liệu tham khảo. Ai không dùng cấm ném đá
Code ô 1
{%set fid=form_url|split('uid=')[1]|split('&')[0]%} <div class="shoutbox"> {% if loged %} <form action="main.php?id=ch_topic_h&uid={{fid}}&back_url=%2Fmain.php" method="post"> <textarea rows="3" cols="20" name="text" style="width:auto"></textarea><br/> <input type="submit" value="Thêm tin nhắn"/></form> {% endif %} <div class="shoutbox_message"> <!-- Z1 --> {% set messages=message_list|split('[mrken_HkxtY24Kym3zX]')%} {%if api.r.get('fnc')!='more_comment'%}{%set a,last=0,api.r.get('last')|default('0')%} {%for i in last..messages|length-2%}{%if '[id_of_msg]' in messages[i] and a < 5%}{%set a=a+1%}{%set last=i+1%}{%set cmt_for=messages[i]|split('[id_of_msg]')[1]|raw %}{{messages[i]|split('[id_of_msg]')[0]|replace({'id=""':'id="'~i~'"'})|raw}}{%set ncmt=0%}{%set cmts%}{%for j in messages|length-2..0%}{%if '[cmt_for]' in messages[j] and cmt_for in messages[j] %}{{messages[j]|split('[cmt_for]')[0]|replace({(cmt_for~' '):''})|raw}}{%set ncmt=ncmt+1%}{%endif%}{%endfor%}{%endset%}<small>{%if ncmt>0%} ({{ncmt}}){%endif%}</small>{%if api.user_id%}{%if api.r.get('fnc')=='comment'%}{%if api.r.get('comment_id')==cmt_for%}<div><form action="main.php?id=ch_topic_h&uid={{fid}}&back_url=%2Fmain.php%3Flast={{api.r.get('last')|default('0')}}" method="post"><input type="text" name="text" style="width:50%" value="{{cmt_for}} {{api.r.get('ans')}}"><input type="submit" value="Comment"/></form></div>{%endif%}{%endif%}{%endif%}{%if ncmt>5%}<div><a href="/main.php?fnc=more_comment&comment_id={{cmt_for}}"><small>Xem thêm {{ncmt-5}} bình luận khác</small></a></div>{%endif%}{{cmts|split('<div class="divide"></div>')|slice(-5,5)|join('<div class="divide"></div>')|raw}}</div></div></div>{%endif%}{%endfor%}{%else%}{%set last=0%}{%for i in 0..messages|length-2%}{%if '[id_of_msg]' in messages[i]%}{%set cmt_for=messages[i]|split('[id_of_msg]')[1]|raw %}{%if cmt_for==api.r.get('comment_id')%}{{messages[i]|split('[id_of_msg]')[0]|raw}}{%set ncmt=0%}{%set cmts%}{%for j in messages|length-2..0%}{%if '[cmt_for]' in messages[j] and cmt_for in messages[j] %}{{messages[j]|split('[cmt_for]')[0]|replace({(cmt_for~' '):''})|raw}}{%set ncmt=ncmt+1%}{%endif%}{%endfor%}{%endset%}<small> ({{ncmt}})</small>{{cmts}}</div></div></div>{%endif%}{%endif%}{%endfor%}{%endif%} </div> <div><a href="/main.php?last={{last}}">Xem thêm</a></div> </div>
Code ô 2
{% set name=nick|striptags|raw %} {% set uid=nick|split('uid=')[1]|split('"')[0] %} {% set user=api.u.get(uid)%} {%if message|slice(0,8) matches '{^[0-3][0-9][0-5][0-9][0-5][0-9][0-2][0-9]}' and message|length >= 10 %}<div class="divide"></div><div class="comment">{{nick}} {{message|raw}}<br/><small>{%if uid!=api.user_id%}<a href="/main.php?fnc=comment&comment_id={{message|split(' ')[0]}}&page=1&ans={{name|raw}}#{{message|split(' ')[0]}}">Trả lời</a> · {%endif%}({{message_date}})</small></div>[cmt_for]{{message|split(' ')[0]}}{%else%}{% set id=message_date|date('disH')%} <div class="sc_a1" id=""><div class="message" id="{{id}}">{%if user.profilephotoid==0%}<img src="/files/154586/{%if user.sex==1%}nam{%elseif user.sex==2%}nu{%else%}unknow{%endif%}20.png" alt="{{user.nick}}" class="ava ava2 ava30 fl"/>{%else%}{{userphoto|replace({'alt="*" class="photo"':'class="ava ava2 ava30 fl"',('ses='~ses~'&'):''})|raw}}{%endif%}<div class="fl ml"><b>{{nick}}</b>{% if user.level==127 %} - <font color="#ff0000">Founder</font>{% endif %}<br/>{{message_date|date("H:i, d/m/Y")|replace({(now|date("d/m/Y")):'Hôm nay'})|raw}}</div><div class="cl"></div><div class="chat_text"><div class="user_message">{%if message|striptags|length > 300 and api.r.get('fnc')!='more_comment'%}{{message|replace({'<br/>':'[br/]'})|striptags|split(' ')|slice(0,49)|join(' ')|replace({'[br/]':'<br/>'})|raw}}...<br/><small><a href="/main.php?fnc=more_comment&comment_id={{id}}">xem thêm</a> »</small>{%else%}{{ message|raw }}{%endif%}</div><small>{% if api.user_id %}{%if uid != api.user_id%}<a rel="nofollow" href="pm.php?id=new&to={{uid}}" class="sp loged dpf">PM</a> · {%endif%}<a href="main.php?fnc=comment&comment_id={{id}}&page={{api.r.get('page')|default('1')}}#{{id}}">Bình luận</a>{%endif%}</small>[id_of_msg]{{id}}{%endif%}[mrken_HkxtY24Kym3zX]
Cài đặt
- Số lượng tin nhắn: 100
- Kích thước ảnh: 40x40 hoặc 30x30 tùy ý
- Dòng mới: Không
CSS
Đặt vào thiết kế > phong cách và màu sắc cho trang web
.shoutbox{background:#dcdee3} .ava{padding:6px} .sc_a1{border:1px solid #ccc;margin:6px;margin-top:0;background:#fff} .fl{float:left}.fr{float:right}.cl{clear:both}.ml{margin-left:10px} .comment,.chat_text form{background:#f6f7f8;padding:4px 6px;border-top:1px solid rgba(0, 0, 0, .101);}
Bấm nút "Quote" để copy dễ hơn