PDA

View Full Version : DedeV5.6分类信息按联动类别筛选的实现方法


Quamba
2014-05-01, 09:23 PM
温馨提醒:本教程适用于DedeCMS V5.6
实现方法:

1. 修改include\taglib\infolink.lib.php,找到:
require_once(DEDEROOT.'/data/enums/infotype.php');

在其下面添加:


require_once(DEDEROOT.'/data/enums/自定义联动类别字段名.php');   
  
function lib_infolink($ctag,$refObj)   
{   
    global $dsql,$nativeplace,$infotype,$自定义联动类别字段名,$hasSetEnumJs,$cfg_cmspath,$cfg_mainsite;   
    global $em_nativeplaces,$em_infotypes,$em_自定义联动类别字段名s;  //看清楚,这里后面的个S   
  
  
$fields = array('nativeplace'=>'','infotype'=>'','自定义联动类别字段名'=>'','typeid'=>$typeid, 'channelid'=>$channelid,'linkallplace'=>'','linkalltype'=>'','linkeall自定义联动类别字段名'=>'');   
       
$fields['nativeplace'] = $fields['infotype'] = $fields['自定义联动类别字段名'] = '';    



找到:
if(is_array($ctp->CTags))

在其下面添加:




$fields['linkalltype'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}'>不限</a>";      
     
//下面添加一行      
     
$fields['linkeall自定义联动类别字段名'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}'>不限</a>";      
     
     
     
         
    //自定义联动类别字段链接      
    if(emptyempty($自定义联动类别字段名))      
    {      
        foreach($em_自定义联动类别字段名s as $eid=>$em)      
        {      
            if($eid % 500 != 0) continue;      
            $fields['自定义联动类别字段名'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&自定义联动类别字段名={$eid}&nativeplace={$nativeplace}'>{$em}</a>";      
        }      
    }      
    else     
    {      
        $sontype = ( ($自定义联动类别字段名 % 500 != 0) ? $自定义联动类别字段名 : 0 );      
      $toptype = ( ($自定义联动类别字段名 % 500 == 0) ? $自定义联动类别字段名 : ( $自定义联动类别字段名-($membertype%500) ) );      
        $fields['自定义联动类别字段名'] = "<a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&自定义联动类别字段名={$toptype}&nativeplace={$nativeplace}'><b>{$em_自定义联动类别字段名s[$toptype]}</b></a> ";      
        foreach($em_自定义联动类别字段名s as $eid=>$em)      
        {      
            if($eid < $toptype+1 || $eid > $toptype+499) continue;      
            if($eid == $自定义联动类别字段名) {      
                $fields['自定义联动类别字段名'] .= " <b>{$em}</b>";      
            }      
            else {      
                $fields['自定义联动类别字段名'] .= " <a href='{$baseurl}plus/list.php?channelid={$channelid}&tid={$typeid}&自定义联动类别字段名={$eid}&nativeplace={$nativeplace}'>{$em}</a>";      
          }      
      }      
    }      




3. 修改 include\arc.sglistview.class.php ,找到:
if(!emptyempty($this->searchArr['keyword']))



//自定义联动类别           
               
      if(!emptyempty($this->searchArr['自定义联动类别字段名']))   
            {   
                if($this->searchArr['自定义联动类别字段名'] % 500 ==0 )   
                {   
                    $naddQuery .= " And arc.自定义联动类别字段名 >= '{$this->searchArr['自定义联动类别字段名']}' And arc.自定义联动类别字段名 < '".($this->searchArr['自定义联动类别字段名']+500)."'";   
                }   
                else  
                {   
                    $naddQuery .= "And arc.自定义联动类别字段名 = '{$this->searchArr['自定义联动类别字段名']}'";   
                }   
            }   




4 . 修改 include\taglib\infoguide.lib.php,找到
$fields['infotype'] .= '<script language="javascript">MakeTopSelect("infotype", '.$infotype.');</script>'."\r\n";
在其下面添加:



$fields['自定义联动类别字段名'] .= "<input type='hidden' id='hidden_自定义联动类别字段名' name='自定义联动类别字段名' value='{$自定义联动类别字段名}' />\r\n";   
    $fields['自定义联动类别字段名'] .= "<span class='infosearchtxt'>类型:</span><span id='span_自定义联动类别字段名'></span>\r\n";   
    $fields['自定义联动类别字段名'] .= "<span id='span_自定义联动类别字段名_son'></span><br />\r\n";   
    $fields['自定义联动类别字段名'] .= "<script language='javascript' type='text/javascript' src='{$cfg_mainsite}{$cmspath}data/enums/自定义联动类别字段名.js'></script>\r\n";   
    $fields['自定义联动类别字段名'] .= '<script language="javascript">MakeTopSelect("自定义联动类别字段名", '.$自定义联动类别字段名.');</script>'."\r\n";