本帖最后由 lxlsje 于 2013-9-26 14:31 编辑
想实现 父版块调用子版块帖子(是分类信息不是普通帖子),求助高手帮忙写一下代码,
function showsorttemplate($sortid, $fid, $sortoptionarray, $templatearray, $threadlist, $threadids = array(), $sortmode = false) {
global $_G;
$searchtitle = $searchvalue = $searchunit = $stemplate = $searchtids = $sortlistarray = $skipaids = $sortdata = array();
/**********************************************************************************************
$fup = DB::result_first("SELECT fid FROM ".DB::table('forum_forum')." WHERE fup = '$fid' and type = 'sub'");
if ($fup.length == 0){
$fids = $fid;
}else {
$fids = $fup;
}
这段代码是我自己加进去的,用来获取 当前 父版块 下的所有 子版块的 fid (这里好像有点问题,就是 $fup 这个变量怎么写一下,才能循环得到所有子版块的fid, 并且赋值给下面这段 语句 红色标注的变量??)
**********************************************************************************************/
$sortthreadlist = array();
foreach(C::t('forum_typeoptionvar')->fetch_all_by_search($sortid, $fids(原来这里是 fid), $threadids) as $sortthread) {
$optionid = $sortthread['optionid'];
$sortid = $sortthread['sortid'];
$tid = $sortthread['tid'];
$arrayoption = $sortoptionarray[$sortid][$optionid];
if($sortoptionarray[$sortid][$optionid]['subjectshow']) {
$_G['optionvaluelist'][$sortid][$tid][$arrayoption['identifier']]['title'] = $arrayoption['title'];
$_G['optionvaluelist'][$sortid][$tid][$arrayoption['identifier']]['unit'] = $arrayoption['unit'];
if(in_array($arrayoption['type'], array('radio', 'checkbox', 'select'))) {
if($arrayoption['type'] == 'checkbox') {
foreach(explode("\t", $sortthread['value']) as $choiceid) {
$sortthreadlist[$tid][$arrayoption['title']] .= $arrayoption['choices'][$choiceid].' ';
$_G['optionvaluelist'][$sortid][$tid][$arrayoption['identifier']]['value'] .= $arrayoption['choices'][$choiceid].' ';
}
} elseif($arrayoption['type'] == 'select') {
$sortthreadlist[$tid][$arrayoption['title']] = $_G['optionvaluelist'][$sortid][$tid][$arrayoption['identifier']]['value'] = $arrayoption['choices'][$sortthread['value']]['content'];
} else {
$sortthreadlist[$tid][$arrayoption['title']] = $_G['optionvaluelist'][$sortid][$tid][$arrayoption['identifier']]['value'] = $arrayoption['choices'][$sortthread['value']];
}
} elseif($arrayoption['type'] == 'image') {
$imgoptiondata = dunserialize($sortthread['value']);
if(empty($templatearray[$sortid])) {
$maxwidth = $arrayoption['maxwidth'] ? 'width="'.$arrayoption['maxwidth'].'"' : '';
$maxheight = $arrayoption['maxheight'] ? 'height="'.$arrayoption['maxheight'].'"' : '';
$sortthreadlist[$tid][$arrayoption['title']] = $_G['optionvaluelist'][$sortid][$tid][$arrayoption['identifier']]['value'] = $imgoptiondata['url'] ? "<img src=\"$imgoptiondata[url]\" onload=\"thumbImg(this)\" $maxwidth $maxheight border=\"0\">" : '';
} else {
$sortthread['value'] = '';
if($imgoptiondata['aid']) {
$sortthread['value'] = getforumimg($imgoptiondata['aid'], 0, 120, 120);
} elseif($imgoptiondata['url']) {
$sortthread['value'] = $imgoptiondata['url'];
}
$sortthreadlist[$tid][$arrayoption['title']] = $_G['optionvaluelist'][$sortid][$tid][$arrayoption['identifier']]['value'] = $sortthread['value'] ? $sortthread['value'] : './static/image/common/nophotosmall.gif';
}
} else {
$sortthreadlist[$tid][$arrayoption['title']] = $_G['optionvaluelist'][$sortid][$tid][$arrayoption['identifier']]['value'] = $sortthread['value'] ? $sortthread['value'] : $arrayoption['defaultvalue'];
}
$sortthreadlist[$tid]['sortid'] = $sortid;
$sortthreadlist[$tid]['expiration'] = $sortthread['expiration'] && $sortthread['expiration'] <= TIMESTAMP ? 1 : 0;
}
}
|