织梦问答二次开发如何读取问和答的内容
织梦
问答二次开发如何读取问和答的内容,如何读取回答者的内容呢?织梦5.7版本不支持dede:sql的标签,找了一天终于找到方法实现下面的效果:织梦问答是使用MVC的框架的,这样好,那么我们到ask的文件里面:然后到model的文件夹,找到mquestion.php的文件,
/**
* 获取问和答两个表的内容
*
* @param int $row
* @return array
*/
function get_qustitontoanser($row = '10',$tid)
{
$arrays = array();
$query = "SELECT a.id, a.title,a.tid2name,a.replies,m.content FROM `dede_ask` a
inner JOIN `dede_askanswer` m ON m.askid=a.id
WHERE a.status= 1 and m.ifanswer=1 and a.tid={$tid} LIMIT 0,$row";
$this->dsql->SetQuery($query);
$this->dsql->Execute();
while($arr = $this->dsql->GetArray())
{
$arrays[] = $arr;
}
return $arrays;
}
解下来在control文件夹找到index.php
添加如下的代码:
//获取栏目一的问题
$solutionsnew = $this->question->get_qustitontoanser(7,1);
//处理链接地址
if($GLOBALS['cfg_ask_rewrite'] == 'Y')
{
$digests = makerewurl($digests,'id');
$notoks = makerewurl($notoks,'id');
$solutions = makerewurl($solutions,'id');
$solutionsnew = makerewurl($solutionsnew,'id');
$rewards = makerewurl($rewards,'id');
}else{
$digests = makeurl($digests,'id');
$notoks = makeurl($notoks,'id');
$solutions = makeurl($solutions,'id');
$solutionsnew = makeurl($solutionsnew,'id');
$rewards = makeurl($rewards,'id');
}
//设定变量值
$GLOBALS['row'] = $row;
$GLOBALS['digests'] = $digests;
$GLOBALS['notoks'] = $notoks;
$GLOBALS['rewards'] = $rewards;
$GLOBALS['solutions'] = $solutions;
$GLOBALS['solutionsnew'] = $solutionsnew;
$GLOBALS['solvenum'] = $solvenum;
//载入模板
$this->SetTemplate('index.htm');
$this->Display();
红色的就是添加的内容,这样就实现了读取织梦的回答的内容呢。
笔记部落
提供的很详细吧。