主頁 > 網(wǎng)站建設(shè) > 建站知識 > 分享:織夢問答模塊可以在后臺修改問答和答案

分享:織夢問答模塊可以在后臺修改問答和答案

POST TIME:2018-03-19 22:20

找了很久的修改問答系統(tǒng)的方法,就是站長在網(wǎng)站后臺就可以修改問題和答案的方法,現(xiàn)在分享給大家,用的到的好評一下。

1.把a(bǔ)sk/include/asktype.inc.php復(fù)制到dede/inc/里面去

2.修改/dede/ask_type第91行

把$sql = "update `dede_asktype` set name='$name', reid='$reid', disorder='$disorder' where id='$id' ";

改成$sql = "update `dede_asktype` set name='$name', reid='$reid', disorder='$disorder',keywords='$keywords',description='$description',title='$title' where id='$id' ";

現(xiàn)在在asktype表里面新增 keywords, description , title三個字段

3.在dede/新建modify_ask.php文件,代碼如下:

<?php

require_once(dirname(__FILE__)."/config.php");
require_once(DEDEINC.'/datalistcp.class.php');

//問題分類
require_once DEDEADMIN.'/inc/asktype.inc.php';

$dlist = new DataListCP();
$sql = "select * from `dede_ask` where id='".intval($askid)."'";
$row = $dsql->GetOne($sql);

if($item == 'mod_ask'){
include(DEDEADMIN."/templets/modify_ask.htm");
}else if($item == 'revert'){
$sql = "select * from `dede_askanswer` where askid='".intval($askid)."'";
$answerArr = $dsql->GetOne($sql);

include(DEDEADMIN."/templets/ask_revert.htm");
}

exit;
?>

4.在dede/ templets/新建modify_ask.htm文件

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="http://viscms.blog.163.com/blog/img/base.css" rel="stylesheet" type="text/css" />
<title>修改問題</title>
<script language="javascript" src="http://viscms.blog.163.com/blog/js/jquery.js"></script>
<script language="javascript">
function showSub(reid){
$.getJSON("subTypes.php?reid="+reid, function(data){
$('#sctTid2').empty();
$.each(data,function(i,row){
$('#sctTid2').append("<option value='"+row.id+"'>"+ row.name + "</option>");
});
});
}

</script>

</head>

<body>

<div>
<form action="ask_admin.php" method="post" name="form1">
<input type="hidden" value="modify" name="action" />
<input type="hidden" value="<?php echo $row['id'];?>" name="askid" />
<table width="420" height="125" border="0" cellpadding="0" cellspacing="0" style="margin-top:15px;">
<tr height="35">
<td width="103" align="right">提問者ID:</td>
<td width="133"><?php echo $row['id'];?></td>
</tr>
<tr height="35">
<td align="right">所屬欄目:</td>
<td><label>
<select name="ClassLevel1" onchange="showSub($(this).val())">
<?php
foreach($asktypes as $t1){
if($t1['reid'] == '0'){
if($row['tid'] == $t1['id']){
$selected = "selected='selected'";
echo "<option value='".$t1['id']."' ".$selected.">".$t1['name']."</option>";
}else{
echo "<option value='".$t1['id']."'>".$t1['name']."</option>";
}
}
}
?>
</select>
</label>
<label>
<select name="ClassLevel2" id="sctTid2">
<?php
foreach($asktypes as $t2){
if($t2['reid'] == $row['tid']){
if($row['tid2'] == $t2['id']){
$selected = "selected='selected'";
echo "<option value='".$t2['id']."' ".$selected.">".$t2['name']."</option>";
}else{
echo "<option value='".$t2['id']."'>".$t2['name']."</option>";
}
}
}
?>
</select>
</label></td>
</tr>
<tr height="35">
<td align="right">提問標(biāo)題:</td>
<td><input name="title" type="text" size="52" height="25" value="<?php echo $row['title'];?>" /></td>
</tr>
<tr height="35">
<td align="right">補(bǔ)充說明:</td>
<td><textarea name="content" cols="50" rows="6"><?php echo $row['content'];?></textarea></td>
</tr>
<tr height="35">
<td align="right">&nbsp;</td>
<td><label>
<input type="submit" name="Submit" value="修改" /></label>
<label>
<input name="cancel" type="reset" id="cancel" value="重置" />
</label></td>
</tr>
<tr height="35">
<td align="right">&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</form>
</div>
</body>
</html>
5.在dede/templets/新建ask_revert文件

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="http://viscms.blog.163.com/blog/img/base.css" rel="stylesheet" type="text/css" />
<title>回復(fù)問題</title>
</head>

<body>
<div>
<form action="ask_admin.php" method="post" name="form1">
<input type="hidden" name="action" value="revert" />
<input type="hidden" name="askid" value="<?php echo $row['id']; ?>" />
<table width="80%" border="1" cellpadding="10" cellspacing="10">
<tr>
<td width="86" align="right">回復(fù)ID:</td>
<td width="370">
<input type="hidden" name="answerid" value="<?php if($answerArr['id'] != ''){ echo $answerArr['id'];}else{ echo 0;}?>" />
<?php if($answerArr['id'] != ''){ echo $answerArr['id'];}else{ echo 0;}?></td>
</tr>
<tr>
<td align="right">問題:</td>
<td><strong><font color="#CC00FF"><?php echo $row['title'];?></font></strong></td>
</tr>
<tr>
<td align="right">補(bǔ)充說明:</td>
<td><font color="#0066CC"><?php echo nl2br($row['content']);?></font></td>
</tr>

<tr>
<td align="right">關(guān)鍵詞(多個請用,號分隔):</td>
<td>
<input type="text" value="<?php echo $row['keywords'];?>" name='keywords'/>
</td>
</tr>
<tr>
<td align="right">回復(fù)內(nèi)容:</td>
<td>
<?php GetEditor("content",$answerArr['content']); ?>
</td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td><label>
<input type="submit" name="Submit" value="提交" />
<input name="cancel" type="reset" id="cancel" value="重填" />
</label></td>
</tr>

</table>
</form>
</div>

</body>
</html>

6.在dede/ask_admin.php第143行加入以下代碼


else if($action == 'modify'){ //修改問題
$ClassLevel1 = intval($ClassLevel1);
$ClassLevel2 = intval($ClassLevel2);
if($ClassLevel2 != 0)
{
$where = "id in ($ClassLevel1,$ClassLevel2)";
}else
{
$where = "id='$ClassLevel1'";
}
$query = "select id, name, reid from `dede_asktype` where $where";

$dsql->Execute('me',$query);
while($row = $dsql->getarray())
{
if($row['id'] == $ClassLevel1)
{
$tidname = $row['name'];
$tid = $row['id'];
}elseif($row['id'] == $ClassLevel2 && $row['reid'] == $ClassLevel1)
{
$tid2name = $row['name'];
$tid2 = $row['id'];
}
}
$sql = "update `dede_ask` set title='{$title}',tid='{$tid}',tidname='{$tidname}',tid2='{$tid2}',tid2name='{$tid2name}',content='{$content}' where id='{$askid}'";
$dsql->ExecuteNoneQuery($sql);
//header('location:ask_admin.php');
ShowMsg("問題修改成功!",'ask_admin.php');
exit;
}else if($action == 'revert'){ //回復(fù)問題
if($answerid){
$sql = "update `dede_askanswer` set content='{$content}' where id='{$answerid}'";
$dsql->ExecuteNoneQuery($sql);
}else{
$dateline = time();
$sql = "insert into `dede_askanswer`(askid,ifanswer,username,content,dateline,ifcheck) values('{$askid}',1,'一六一醫(yī)院專家','{$content}','{$dateline}',1)";
$dsql->ExecuteNoneQuery($sql);
}
$keywords = $_POST['keywords'];
$description = $_POST['description'];

//修改問題狀態(tài)
$sql = "UPDATE `dede_ask` set status='1',replies='1',keywords='{$keywords}',description='$description' where id='{$askid}'";
$dsql->ExecuteNoneQuery($sql);
ShowMsg("問題回復(fù)成功!",'ask_admin.php');
exit;
}

7.在ask表中加入以下字段keywords,description,username
 

8.修改browser.php第35來始的整個if條件包括elseif
if($tid)
{
$dsql->Execute('me',"select * from `dede_asktype` where id='$tid' ");
if(!$typeinfo = $dsql->getarray())
{
showmsgs('browser_notexists','index.php');
exit;
}
$wheresql .= " tid='$tid' ";
$multistr .="tid=$tid";
$tidstr = "tid=$tid";

if($typeinfo['title'] == ''){
$navtitle = $typeinfo['name'];
}else{
$navtitle = $typeinfo['title'];
}


$nav = " $symbols <a href=&;browser.php?tid=$tid&;>".$typeinfo['name'].'</a>';

$toptypeinfo = $typeinfo;

}
elseif($tid2)
{
$dsql->Execute('me',"select * from `dede_asktype` where id='$tid2' ");
if(!$typeinfo = $dsql->getarray())
{
showmsgs('browser_notexists','index.php');
exit;
}
$wheresql .= "tid2='$tid2'";
$multistr .="tid2=$tid2";
$tidstr = "tid2=$tid2";

$toptypeinfo = $dsql->getone("select id, name, asknum from `dede_asktype` where id='".$typeinfo['reid']."' limit 1");

if($typeinfo['title'] == ''){
$navtitlestr = $typeinfo['name'];
}else{
$navtitlestr = $typeinfo['title'];
}

$navtitle = $navtitlestr.' '.$toptypeinfo['name'];

$nav = ' '.$symbols.' <a href="browser.php?tid='.$toptypeinfo['id'].'">'.$toptypeinfo['name'].'</a> '.$symbols.' <a href="browser.php?tid2='.$tid2.'">'.$typeinfo['name'].'</a>';

}

9.在所有的browser.htm里面加入

<meta name="keywords" content="<?php echo $typeinfo['keywords']?>" />
<meta name="description" content="<?php echo $typeinfo['description']?>" />

10.在question.php第30行加入
if($question['tid2']!=0){
$myquestiontid= $question['tid2'];
}else{
$myquestiontid= $question['tid'];
}
$myquestiontype=$dsql->getone("select * from `dede_asktype` where id=$myquestiontid");

11.找到//等級上面加入
//上,下一條問題

if($question[tid2]){
$myupdowntype="tid2=$question[tid2]";
}
else{
$myupdowntype="tid=$question[tid]";
}

$mydown= $dsql->getone("SELECT id,title FROM `dede_ask` WHERE $myupdowntype and status>='0' and id>'$id' order by id asc limit 0,1");
$myup= $dsql->getone("SELECT id,title FROM `dede_ask` WHERE $myupdowntype and status>='0' and id< '$id' order by id desc limit 0,1");

if($myup){
$myuplink="<a href=/question.php?id=$myup[id]>$myup[title]</a> ";
}
if($mydown){
$mydownlink="<a href=/question.php?id=$mydown[id]>$mydown[title]</a> ";
}

12.在question.htm中加入
<meta name="keywords" content="<?php echo $question['title'].",".$question['keywords'].",".str_replace("_",",",$myquestiontype['title']);?>" />
<meta name="description" content="<?php echo $question['content'].$question['description']?>" />

13.ask_type.htm中加入
<tr>
<td bgcolor="#FFFFFF">網(wǎng)頁title:</td>
<td bgcolor="#F8FCF1"><textarea name="title"><?php echo $sector['title']; ?></textarea></td>
</tr>
<tr>
<td bgcolor="#FFFFFF">關(guān)鍵字:</td>
<td bgcolor="#F8FCF1"><textarea name="keywords"><?php echo $sector['keywords']; ?></textarea></td>
</tr>
<tr>
<td bgcolor="#FFFFFF">描述:</td>
<td bgcolor="#F8FCF1"><textarea name="description"><?php echo $sector['description']; ?></textarea></td>
</tr>

14.在ask_admin.htm中加入
<link href="http://viscms.blog.163.com/blog/js/thickbox.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="http://viscms.blog.163.com/blog/js/jquery.js"></script>
<script language="javascript" src="http://viscms.blog.163.com/blog/js/thickbox.js"></script>

15.在ask中else if($action == 'delete')上面加入
else if($action == 'search'){
require_once(DEDEINC.'/datalistcp.class.php');
if($_POST['selecttype'] =="tid2" ||$_POST['selecttype'] =="uid"||$_POST['selecttype'] =="reward"||$_POST['selecttype'] =="status"){
$wheresql ="where ".$_POST['selecttype']." = ".$_POST['search']."";

}else{
$wheresql ="where ".$_POST['selecttype']." like '%".$_POST['search']."%'";
}
$query = "select * from `dede_ask` $wheresql order by id desc";
updatecount();
$dlist = new DataListCP();
$dlist->pageSize = 20;
$dlist->SetParameter("tid",$tid);
$dlist->SetParameter("tid2",$tid2);
$dlist->SetParameter("status",$status);
$dlist->SetTemplet(DEDEADMIN."/templets/ask_admin.htm");
$dlist->SetSource($query);
$dlist->Display();
}

16.在ask_admin.htm中找到,未審核的問題</a></b>加入
<div style=" float:left">
<form method="POST" action="ask_admin.php?action=search">
搜索類型:
<select name="selecttype">
<option value="tidname">頂層欄目名稱</option>
<option value="tid2">上級欄目號</option>
<option value="tid2name">上級欄目名稱</option>
<option value="uid">用戶號</option>
<option value="title" selected>標(biāo)題</option>
<option value="reward">回答數(shù)</option>
<option value="status">問題狀態(tài)</option>
<option value="content">問題包含內(nèi)容</option>
<option value="ip">提問者IP</option>
</select>
<input type="text" name="search" style="width:200px;"> <input type="submit" value="提交">
</form>
</div>

對應(yīng)的地方加入
<td><a href="http://viscms.blog.163.com/blog/modify_ask.php?item=mod_ask&askid=<?php echo $fields['id']; ?>" title="修改問題:">修改問題</a> &nbsp;|&nbsp;
<a href="http://viscms.blog.163.com/blog/modify_ask.php?item=revert&askid=<?php echo $fields['id']; ?>" title="問題回復(fù)修改:">回復(fù)</a>
</td>

17.在ask_answer.htm中找到未審核的答案</a></b>加入
<div style=" float:left">
<form method="POST" action="ask_answer.php?action=search">
搜索類型:
<select name="selecttype">
<option value="username">用戶名</option>
<option value="content" selected>回答包含內(nèi)容</option>
<option value="ip">回答者IP</option>
</select>
<input type="text" name="search" style="width:200px;"> <input type="submit" value="提交">
</form>
</div>
在ask_answer.php中找到117行加入
else if ($action =="search"){
CheckPurview('a_Commend,sys_ArcBatch,ask_AllowAll');
if($_POST['selecttype'] =="username"||$_POST['selecttype'] =="ip"){
$wheresql ="where ".$_POST['selecttype']." = &;".$_POST['search']."&;";
}else{
$wheresql ="where ".$_POST['selecttype']." like '%".$_POST['search']."%'";
}
$query = "select * from `dede_askanswer` $wheresql order by id desc";
updatecount();
$dlist = new DataListCP();
$dlist->pageSize = 20;
$dlist->SetParameter("tid",$tid);
$dlist->SetParameter("tid2",$tid2);
$dlist->SetParameter("check",$check);
$dlist->SetTemplet(DEDEADMIN."/templets/ask_answer.htm");
$dlist->SetSource($query);
$dlist->Display();
exit();
}
18.在question.htm中加入
htmlspecialchars_decode($answer['content'])



收縮
  • 微信客服
  • 微信二維碼
  • 電話咨詢

  • 400-1100-266