分享:织梦问答模块可以在后台修改问答和答案

找了很久的修改问答系统的方法,就是站长在网站后台就可以修改问题和答案的方法,现在分享给大家,用的到的好评一下。

1.把ask/include/asktype.inc.php复制到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' ";

现在在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">提问标题:</td>
<td><input name="title" type="text" size="52" height="25" value="<?php echo $row['title'];?>" /></td>
</tr>
<tr height="35">
<td align="right">补充说明:</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>回复问题</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">回复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">补充说明:</td>
<td><font color="#0066CC"><?php echo nl2br($row['content']);?></font></td>
</tr>

<tr>
<td align="right">关键词(多个请用,号分隔):</td>
<td>
<input type="text" value="<?php echo $row['keywords'];?>" name='keywords'/>
</td>
</tr>
<tr>
<td align="right">回复内容:</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'){            //回复问题
    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,'一六一医院专家','{$content}','{$dateline}',1)";
        $dsql->ExecuteNoneQuery($sql);
    }
    $keywords = $_POST['keywords'];
    $description = $_POST['description'];
    
    //修改问题状态
    $sql = "UPDATE `dede_ask` set status='1',replies='1',keywords='{$keywords}',description='$description' where id='{$askid}'";
    $dsql->ExecuteNoneQuery($sql);
    ShowMsg("问题回复成功!",'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">网页title:</td>
        <td bgcolor="#F8FCF1"><textarea name="title"><?php echo $sector['title']; ?></textarea></td>
    </tr>
    <tr>
        <td bgcolor="#FFFFFF">关键字:</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>标题</option>
    <option value="reward">回答数</option>
    <option value="status">问题状态</option>
    <option value="content">问题包含内容</option>
    <option value="ip">提问者IP</option>
</select>
<input type="text" name="search" style="width:200px;"> <input type="submit" value="提交">
</form>
</div>

对应的地方加入
<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="问题回复修改:">回复</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>回答包含内容</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'])
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

dedecms织梦默认的TAG标签不是很灵活。有时候我们的标签需要进行一个分类,能不能像{dede:arclist}标签的自定义属性(如:flag=c,h),这样全站调用的时候更灵活。 全站调用TAG标签方法一般是: {dede:tag row='100' sort='new' getall='1'}a target="_blank
未审核文档的TAG会显示在TAG列表页面, 固然点击进入TAG时, 相关的未审核文章不会显示出来, 这样对用户体验是很不好的. DEDECMS暂时没有提供这个功能,所以要解决这个问题, 让DEDECMS不显示未审核文档的TAG, 就要修改TAG的显示库文件 tag.lib.php。 方法一 打
我们都知道DEDECMS生成的文件夹是按天生成的,只要传了图片就会自动建立个年月日的文件,centos系统下,都是随便排序的,很难找到对应文件夹,如果要按顺序排列,要怎么操作呢? 一、文件管理器: 修改 /dede/templets/file_manage_main.html $dh = dir($inp
我们在用到织梦dedecms软件模型的时候,手动指定地址通常只能是引用其他网址或者链接,我们要实现直接选取站内的文件,这个要怎么操作呢?下面小编一步步为您解答,最终效果如下图所示: 实现教程 1、打开 /dede/templets/soft_add.htm 找到 input type=text
我们有时候需要对织梦文档的点击量进行批量维护,比如采集来的文章,点击量都为0,需要批量修改,可以用到如下方法1。 1、在数据库里运行下面的代码就可以了,文章的点击量变得随机从500到1000 UPDATE dede_archives SET click=FLOOR(500 + (RAND() * 1000))
用过dedecms的朋友都知道,织梦cms后台系统基本参数里是无法直接上传图片的,我们更换logo图只能到ftp里替换,非常的不方便,我们如果想直接在系统基本参数里上传,要怎么处理呢?在这里需要对代码进行修改,具体流程如下: 实现方法,打开/dede/templets/sy