dedecms 调用ask问答模块时 可以使用一下方法

{dede:ask qtype=’ok’ row=’1′ getanswer=’Y'}
<strong><a target=”_blank” href=”[field:arcurl /]” title=”[field:fulltitle /]“>[field:title /]</a></strong>
<p> [field:bestanswer function='cn_substr(html2text(@me),70)' /]… <a class=”xx” target=”_blank” href=”[field:arcurl /]“>[详细]</a></p>
{/dede:ask}

要用上面的方法是要修改ask标签的 找到\include\taglib\ ask.lib.php

<?php if(!defined(‘DEDEINC’)) exit(‘Request Error!’);
/**
* 问答调用标签
*
* @version $Id: ask.lib.php 1 9:29 2010年7月6日Z tianya $
* @package DedeCMS.Taglib
* @copyright Copyright (c) 2007 – 2010, DesDev, Inc.
* @license http://help.dedecms.com/usersguide/license.html
* @link http://www.dedecms.com
*/
function lib_ask(&$ctag,&$refObj)
{
global $dsql, $envs, $cfg_dbprefix, $cfg_cmsurl,$cfg_ask_directory,$cfg_ask_isdomain,$cfg_ask_domain,$cfg_ask_url,$cfg_ask_directory;
if($cfg_ask_url == ”) $cfg_ask_url = ‘/ask’;
//属性处理
$attlist=”row|6,qtype|new,tid|0,titlelen|24,getanswer|N”;
FillAttsDefault($ctag->CAttribute->Items,$attlist);
extract($ctag->CAttribute->Items, EXTR_SKIP);
if( !$dsql->IsTable(“{$cfg_dbprefix}ask”) ) return ‘没安装问答模块’;

//启用二级域名
if($cfg_ask_isdomain == ‘Y’)
{
$weburl = $cfg_ask_domain.’/';
}else{
$weburl = $cfg_ask_directory.’/';
}

$innertext = $ctag->GetInnerText();
if(trim($innertext)==”) $innertext = GetSysTemplets(“asks.htm”);

$qtypeQuery = ”;
if($tid > 0) $tid = ” (tid=$tid Or tid2=’$tid’) AND “;
else $tid = ”;
//推荐问题
if($qtype==’commend’) $qtypeQuery = ” $tid digest=1 ORDER BY dateline DESC “;
//新解决问题
else if($qtype==’ok’) $qtypeQuery = ” $tid status=1 ORDER BY solvetime DESC “;
//高分问题
else if($qtype==’high’) $qtypeQuery = ” $tid status=0 ORDER BY reward DESC “;
//随机
else if($qtype==’randtj’) $qtypeQuery = ” $tid status=’1′ AND digest=1 order by rand() “;
//新问题
else $qtypeQuery = ” $tid status=0 ORDER BY disorder DESC, dateline DESC “;

//已经解决的
if($getanswer == ‘Y’) $addsql = ” bestanswer>0 AND “;

$ctp = new DedeTagParse();
$ctp->SetNameSpace(‘field’, ‘[', ']‘);

$solvingask = ”;
$query = “SELECT id, tid, tidname, tid2, tid2name,bestanswer, title,dateline FROM `#@__ask` WHERE $addsql $qtypeQuery limit 0, $row”;

if($qtype==’ok’)
{
$query = “select a.id, a.tid, a.tidname, a.tid2,a.bestanswer, a.tid2name, a.title, a.content,an.dateline,an.askid from `#@__ask` a left join `#@__askanswer` an on an.askid=a.id where $addsql $tid status=1 order by an.dateline desc limit 0, $row”;
}
$dsql->Execute(‘me’,$query);
while($rs = $dsql->GetArray(‘me’))
{
if($getanswer == ‘Y’)
{
if($rs['bestanswer'] > 0)
{
$rs2 = $dsql->GetOne(“SELECT * FROM #@__askanswer WHERE id=’$rs[bestanswer]‘ AND askid=’$rs[id]‘ “);
$rs['bestanswer'] = $rs2['content'];
} else {
$rs['bestanswer'] = ‘NONE’;
}
}

$rs['title'] = cn_substr($rs['title'], $titlelen);
$rs['fulltitle'] = $rs['title'];
$rs['content'] = cn_substr($rs['content'], $titlelen);
$ctp->LoadSource($innertext);
if($rs['tid2name'] != ”)
{
$rs['tid'] = $rs['tid2'];
$rs['tidname'] = $rs['tid2name'];
}
$rs['url'] = $weburl.”qid{$rs['id']}”;
$rs['typeurl'] = $weburl.”t1{$rs['tid']}”;
if($GLOBALS['cfg_ask_rewrite']==’Y')
{
$rs['url'] = $weburl.”question-id-{$rs['id']}”.”.html”; //ask/?ct=question&askaid=[field:id/] ask/?ct=question&askaid=5
$rs['typeurl'] = $weburl.”browser-tid-{$rs['tid']}”.”.html”;
} else {
$rs['url'] = $cfg_ask_url.”/?ct=question&askaid={$rs['id']}”;
$rs['typeurl'] = $cfg_ask_url.”/browser.php?tid={$rs['tid']}”;
}

$rs['arcurl'] = $rs['url'];
foreach($ctp->CTags as $tagid=>$ctag) {
if(!empty($rs[strtolower($ctag->GetName())])) {
$ctp->Assign($tagid,$rs[$ctag->GetName()]);
}
}

$solvingask .= $ctp->GetResult();
}
return $solvingask;
}

*********************************************************

也可以使用 sql语法:

{dede:sql sql=”select dede_ask.id,dede_ask.title,dede_askanswer.content from dede_ask LEFT JOIN dede_askanswer on dede_ask.id=dede_askanswer.askid where dede_askanswer.ifanswer=1 and dede_askanswer.ifcheck=1 or dede_ask.bestanswer=dede_askanswer.id order by dede_ask.id desc LIMIT 0,1″}
<p><b class=”red”>问:</b>[field:title function=cn_substr(@me,46)/]</p>
<p class=”wd”><b class=”red”>答:</b>[field:content function=cn_substr(html2text(@me),60)/]…<a class=”red” href=”[field:url/]” target=”_blank”>[详细]</a></p>
{/dede:sql}

这样 就可以将 回答的内容都调用出来了

Sorry, the comment form is closed at this time.

   
© 2012 Ai-WEB的博客 Suffusion theme by Sayontan Sinha