




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
第php無限級分類實(shí)現(xiàn)評論及回復(fù)功能(1).展示頁面的整體結(jié)構(gòu)設(shè)計(jì)
實(shí)際效果:
頁面html代碼:
!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN""/TR/html4/loose.dtd"
htmllang="en"
head
metahttp-equiv="Content-Type"content="text/html;charset=UTF-8"
titlephp無限級分類實(shí)戰(zhàn)————評論及回復(fù)功能/title
linkrel="stylesheet"type="text/css"href="/Public/css/comment.css"rel="externalnofollow"
scripttype="text/javascript"src="/Public/js/jquery-1.11.3.min.js"/script
scripttype="text/javascript"src="/Public/js/comment.js"/script
/head
body
div
!--發(fā)表評論區(qū)begin--
div
div
span{$num}條評論/span
/div
div
div
textareareplyid="0"/textarea
/div
div
aparent_id="0"style=""href="javascript:void(0);"rel="externalnofollow"rel="externalnofollow"rel="externalnofollow"rel="externalnofollow"rel="externalnofollow"spanstyle=''發(fā)表評論/span/a
/div
/div
/div
!--發(fā)表評論區(qū)end--
!--評論列表顯示區(qū)begin--
!--{$commentlist}--
div
divspan全部評論/span/div
div
!--一級評論列表begin--
volistname="commlist"id="data"
licomment_id="{$data.id}"
div
div
imgsrc="{$data.head_pic}"alt=""
/div
div
div
span{$data.nickname}/span
span{$data.create_time}/span
/div
div
{$data.content}
/div
div
acomment_id="{$data.id}"href="javascript:void(0);"rel="externalnofollow"rel="externalnofollow"rel="externalnofollow"rel="externalnofollow"rel="externalnofollow"回復(fù)/a
/div
/div
/div
!--二級評論begin--
volistname="data.children"id="child"
licomment_id="{$child.id}"
div
div
imgsrc="{$child.head_pic}"alt=""
/div
div
div
span{$child.nickname}/span
span{$child.create_time}/span
/div
div
{$child.content}
/div
div
areplyswitch="off"comment_id="{$child.id}"href="javascript:void(0);"rel="externalnofollow"rel="externalnofollow"rel="externalnofollow"rel="externalnofollow"rel="externalnofollow"回復(fù)/a
/div
/div
/div
!--三級評論begin--
volistname="child.children"id="grandson"
licomment_id="{$grandson.id}"
div
div
imgsrc="{$grandson.head_pic}"alt=""
/div
div
div
span{$grandson.nickname}/span
span{$grandson.create_time}/span
/div
div
{$grandson.content}
/div
div
!--acomment_id="1"href="javascript:void(0);"rel="externalnofollow"rel="externalnofollow"rel="externalnofollow"rel="externalnofollow"rel="externalnofollow"回復(fù)/a--
/div
/div
/div
/li
/volist
/ul
!--三級評論end--
/li
/volist
/ul
!--二級評論end--
/li
/volist
/ul
!--一級評論列表end--
/div
/div
!--評論列表顯示區(qū)end--
/div
/body
/html
(2).單個(gè)評論信息div結(jié)構(gòu)代碼
div
div
imgsrc="{$data.head_pic}"alt=""
/div
div
div
span{$data.nickname}/span
span{$data.create_time}/span
/div
div
{$data.content}
/div
div
acomment_id="{$data.id}"href="javascript:void(0);"rel="externalnofollow"rel="externalnofollow"rel="externalnofollow"rel="externalnofollow"rel="externalnofollow"回復(fù)/a
/div
/div
/div
對應(yīng)的效果圖:
對應(yīng)的css代碼:
.head-pic{
width:40px;
height:40px;
position:relative;
top:0px;
left:40px;
top:-40px;
width:600px;
.cm-header{
padding-left:5px;
.cm-content{
padding-left:5px;
.cm-footer{
padding-bottom:15px;
text-align:right;
border-bottom:1pxdotted#CCC;
.comment-reply{
text-decoration:none;
color:gray;
font-size:14px;
4.JS代碼
(1).提交評論:提交評論的a標(biāo)簽按鈕引用了樣式comment-submit,在其點(diǎn)擊事件中進(jìn)行ajax操作
$('body').delegate('.comment-submit','click',function(){
varcontent=$.trim($(this).parent().prev().children("textarea").val());//根據(jù)布局結(jié)構(gòu)獲取當(dāng)前評論內(nèi)容
$(this).parent().prev().children("textarea").val("");//獲取完內(nèi)容后清空輸入框
if(""==content){
alert("評論內(nèi)容不能為空!");
}else{
varcmdata=newObject();
cmdata.parent_id=$(this).attr("parent_id");//上級評論id
cmdata.content=content;
cmdata.nickname="游客";//測試用數(shù)據(jù)
cmdata.head_pic="/Public/images/default.jpg";//測試用數(shù)據(jù)
varreplyswitch=$(this).attr("replyswitch");//獲取回復(fù)開關(guān)鎖屬性
$.ajax({
type:"POST",
url:"/index.php/home/index/addComment",
data:{
comment:JSON.stringify(cmdata)
dataType:"json",
success:function(data){
if(typeof(data.error)=="undefined"){
$(".comment-reply").next().remove();//刪除已存在的所有回復(fù)div
//更新評論總數(shù)
$(".comment-num").children("span").html(data.num+"條評論");
//顯示新增評論
varnewli="";
if(cmdata.parent_id=="0"){
//發(fā)表的是一級評論時(shí),添加到一級ul列表中
newli="licomment_id='"+data.id+"'divdivimgsrc='"+data.head_pic+"'alt=''/divdivdivspan"+data.nickname+"/spanspan"+data.create_time+"/span/divdivp"+data.content+"/p/divdivacomment_id='"+data.id+"'href='javascript:void(0);'回復(fù)/a/div/div/divul/ul/li
$(".comment-ul").prepend(newli);
}else{
//否則添加到對應(yīng)的孩子ul列表中
if('off'==replyswitch){//檢驗(yàn)出回復(fù)關(guān)閉鎖存在,即三級評論不再提供回復(fù)功能
newli="licomment_id='"+data.id+"'divdivimgsrc='"+data.head_pic+"'alt=''/divdivdivspan"+data.nickname+"/spanspan"+data.create_time+"/span/divdivp"+data.content+"/p/divdiv/div/div/divul/ul/li
}else{//二級評論的回復(fù)按鈕要添加回復(fù)關(guān)閉鎖屬性
newli="licomment_id='"+data.id+"'divdivimgsrc='"+data.head_pic+"'alt=''/divdivdivspan"+data.nickname+"/spanspan"+
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 咖啡店抗疫活動方案
- 周日活動肯德基活動方案
- 團(tuán)隊(duì)消防活動方案
- 團(tuán)體活動過橋活動方案
- 哲學(xué)教研活動方案
- 團(tuán)隊(duì)公司野餐活動方案
- 商行促銷活動方案
- 商店爆破活動方案
- 團(tuán)年活動尋寶活動方案
- 國慶安全出行活動方案
- GB/T 43543-2023漱口水
- 鋼廠燒結(jié)機(jī)安裝施工組織設(shè)計(jì)
- 國家開放大學(xué)電大??啤稇椃▽W(xué)》2025期末試題及答案
- 電信營業(yè)廳規(guī)章制度范文(2篇)
- 火龍罐療法經(jīng)典課件
- 德國司法鑒定培訓(xùn)心得
- xxxx智能化工程施工進(jìn)度計(jì)劃表
- 汽車修理廠管理制度
- 孫正聿《哲學(xué)通論》(修訂版)配套題庫【考研真題精選+專項(xiàng)題庫】
- 2023無損檢測技術(shù)資格人員考試泄漏檢測試卷(練習(xí)題庫)
- 國開電大本科《理工英語4》機(jī)考總題庫
評論
0/150
提交評論