- 积分
- 108
- 在线时间
- 小时
- 注册时间
- 2011-6-28
- 最后登录
- 1970-1-1
|
模板选择choices字段时显示不正常,对visitedshow(),neighborhood()进行改进可以解决问题:
- function visitedshow($tids, $sortoptionarray, $sortid, $template, $modurl) {
- global $_G;
- $optionlist = $data = $datalist = $searchvalue = $searchunit = $stemplate = $_G['optionvisitlist'] = array();
- $valuefield = '';
- foreach($sortoptionarray as $optionid => $option) {
- if($option['visitedshow']) {
- $valuefield .= ','.$option['identifier'];
- $optionlist[$option['identifier']]['unit'] = $option['unit'];
- $optionlist[$option['identifier']]['type'] = $option['type']; //dima:新增
- $optionlist[$option['identifier']]['choices'] = $option['choices']; //dima:新增
- $searchvalue[] = '/\[('.$option['identifier'].')value\]/e';
- $searchunit[] = '/\[('.$option['identifier'].')unit\]/e';
- }
- }
- if($tids && is_array($tids)) {
- $query = DB::query("SELECT tid $valuefield FROM ".DB::table('category_sortvalue')."$sortid WHERE tid IN (".dimplode($tids).")");
- while($thread = DB::fetch($query)) {
- foreach($optionlist as $identifier => $option) {
- $_G['optionvisitlist'][$thread['tid']][$identifier]['unit'] = $option['unit'];
- if(in_array($option['type'], array('radio', 'checkbox', 'select'))){ //dima:这里增加了一个if ... else ... 判断
- $_G['optionvisitlist'][$thread['tid']][$identifier]['value'] = '';
- foreach(explode("\t", $thread[$identifier]) as $choiceid) {
- $_G['optionvisitlist'][$thread['tid']][$identifier]['value'] .= $option['choices'][$choiceid].' ';
- }
- }else{
- $_G['optionvisitlist'][$thread['tid']][$identifier]['value'] = $thread[$identifier]; //dima:原来只有这一行
- }
- $data[$thread['tid']] = $thread['tid'];
- }
- }
- foreach($data as $tid => $option) {
- $stemplate[$tid] = preg_replace(array("/\[url\](.+?)\[\/url\]/i"),
- array("<a href="$modurl?mod=view&tid=$tid">\\1</a>"
- ), stripslashes($template));
- $stemplate[$tid] = preg_replace($searchvalue, "showvisitlistoption('\\1', 'value', '$tid')", $stemplate[$tid]);
- $stemplate[$tid] = preg_replace($searchunit, "showvisitlistoption('\\1', 'unit', '$tid')", $stemplate[$tid]);
- }
- if(!empty($data)) {
- foreach(array_reverse($tids) as $tid) {
- if($data[$tid]) {
- $datalist[$tid] = $stemplate[$tid];
- }
- }
- }
- }
- return $datalist;
- }
复制代码- function neighborhood($tid, $sortid, $cityid, $districtid, $streetid, $sortoptionarray, $template, $modurl) {
- global $_G;
- $optionlist = $data = $datalist = $searchvalue = $searchunit = $stemplate = $imagelist = $_G['optionvaluelist'] = array();
- $valuefield = '';
- foreach($sortoptionarray as $optionid => $option) {
- if($option['visitedshow']) {
- $valuefield .= ','.$option['identifier'];
- $optionlist[$option['identifier']]['unit'] = $option['unit'];
- $optionlist[$option['identifier']]['type'] = $option['type']; //dima:新增
- $optionlist[$option['identifier']]['choices'] = $option['choices']; //dima:新增
- $searchvalue[] = '/\[('.$option['identifier'].')value\]/e';
- $searchunit[] = '/\[('.$option['identifier'].')unit\]/e';
- $optionlist['attachid'] = '';
- }
- }
- $query = DB::query("SELECT tid, attachid $valuefield FROM ".DB::table('category_sortvalue')."$sortid WHERE city='$cityid' AND district='$districtid' AND street='$streetid' AND tid!='$tid' ORDER BY dateline DESC LIMIT 5");
- while($thread = DB::fetch($query)) {
- foreach($optionlist as $identifier => $option) {
- $_G['optionvaluelist'][$thread['tid']][$identifier]['unit'] = $option['unit'];
- if(in_array($option['type'], array('radio', 'checkbox', 'select'))){ //dima:这里增加了一个if ... else ... 判断
- $_G['optionvaluelist'][$thread['tid']][$identifier]['value'] = '';
- foreach(explode("\t", $thread[$identifier]) as $choiceid) {
- $_G['optionvaluelist'][$thread['tid']][$identifier]['value'] .= $option['choices'][$choiceid].' ';
- }
- }else{
- $_G['optionvaluelist'][$thread['tid']][$identifier]['value'] = $thread[$identifier]; //dima:原来只有这一行
- }
- if($identifier == 'attachid') {
- $imagelist[$thread['tid']] = $thread['attachid'] ? '<img src="'.getcateimg($thread['attachid'], 0, 48, 48).'">' : '<img src="template/default/category/images/noupload.gif" width="48" height="48">';
- } else {
- $data[$thread['tid']] = $thread['tid'];
- }
- }
- }
复制代码
修改修的文件:
function_category.rar
(10.42 KB, 下载次数: 1)
|
评分
-
查看全部评分
|