




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
第php無限級(jí)分類實(shí)現(xiàn)評(píng)論及回復(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無限級(jí)分類實(shí)戰(zhàn)————評(píng)論及回復(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ā)表評(píng)論區(qū)begin--
div
div
span{$num}條評(píng)論/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ā)表評(píng)論/span/a
/div
/div
/div
!--發(fā)表評(píng)論區(qū)end--
!--評(píng)論列表顯示區(qū)begin--
!--{$commentlist}--
div
divspan全部評(píng)論/span/div
div
!--一級(jí)評(píng)論列表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
!--二級(jí)評(píng)論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
!--三級(jí)評(píng)論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
!--三級(jí)評(píng)論end--
/li
/volist
/ul
!--二級(jí)評(píng)論end--
/li
/volist
/ul
!--一級(jí)評(píng)論列表end--
/div
/div
!--評(píng)論列表顯示區(qū)end--
/div
/body
/html
(2).單個(gè)評(píng)論信息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
對(duì)應(yīng)的效果圖:
對(duì)應(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).提交評(píng)論:提交評(píng)論的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)前評(píng)論內(nèi)容
$(this).parent().prev().children("textarea").val("");//獲取完內(nèi)容后清空輸入框
if(""==content){
alert("評(píng)論內(nèi)容不能為空!");
}else{
varcmdata=newObject();
cmdata.parent_id=$(this).attr("parent_id");//上級(jí)評(píng)論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
//更新評(píng)論總數(shù)
$(".comment-num").children("span").html(data.num+"條評(píng)論");
//顯示新增評(píng)論
varnewli="";
if(cmdata.parent_id=="0"){
//發(fā)表的是一級(jí)評(píng)論時(shí),添加到一級(jí)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{
//否則添加到對(duì)應(yīng)的孩子ul列表中
if('off'==replyswitch){//檢驗(yàn)出回復(fù)關(guān)閉鎖存在,即三級(jí)評(píng)論不再提供回復(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{//二級(jí)評(píng)論的回復(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等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年高級(jí)會(huì)計(jì)知識(shí)清單與復(fù)習(xí)試題及答案
- 業(yè)主授權(quán)合同范例
- 酒店顧客滿意提升舉措試題及答案
- 代理書畫銷售合同范例
- 買車訂金合同范例
- 乳品廠庫房改造合同范例
- 4050補(bǔ)貼合同范例
- 保險(xiǎn)委托服務(wù)合同范例
- 設(shè)計(jì)師考試中多渠道復(fù)習(xí)的資源整合與應(yīng)用試題及答案
- 工程管理信息系統(tǒng)試題及答案
- 2024年04月江蘇省農(nóng)業(yè)農(nóng)村廳直屬事業(yè)單位2024年公開招考工作人員筆試歷年高頻考題摘選后附答案詳解
- 多圖中華民族共同體概論課件第十三講先鋒隊(duì)與中華民族獨(dú)立解放(1919-1949)根據(jù)高等教育出版社教材制作
- 傷口造口進(jìn)修匯報(bào)護(hù)理
- 口才與演講實(shí)訓(xùn)教程智慧樹知到期末考試答案2024年
- 檔案整理及數(shù)字化服務(wù)售后服務(wù)方案
- 打造消費(fèi)天堂(百貨公司與近代城市文化)
- 2024年一年級(jí)《體育與健康》全冊(cè)教案
- 臂叢神經(jīng)損傷康復(fù)護(hù)理
- 2023路用熱拌環(huán)氧瀝青
- 建筑工程《擬投入本項(xiàng)目的主要施工設(shè)備表及試驗(yàn)檢測儀器設(shè)備表》
- 【高中語文】《紅樓夢》+日常生活描寫所表現(xiàn)的文化內(nèi)涵+統(tǒng)編版高中語文必修下冊(cè)
評(píng)論
0/150
提交評(píng)論