欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

dedecms 给栏目添加自定义的字段 有大用

shiping1 的头像
1) 在 dede_arctype 这个表里增加四个字段 
varchar(300)utf8_general_ci   浏览非重复值 (DISTINCT)修改删除主键唯一索引全文搜索
varchar(50)utf8_general_ci   浏览非重复值 (DISTINCT)修改删除主键唯一索引全文搜索
varchar(50)utf8_general_ci   浏览非重复值 (DISTINCT)修改删除主键唯一索引全文搜索
varchar(50)utf8_general_ci   浏览非重复值 (DISTINCT)修改删除主键唯一索引全文搜索
2) /后台/templets/catalog_add.htm 约 354行以下 增加 
 <!--自定义字段开始-->
           <tr> 
            <td class='bline' height="26" style="padding-left:10px;"><font color='green'>自定义内容:</font></td>
            <td class='bline'><input name="customcontent" type="text" id="customcontent" size="100" value="" class="iptxt" /></td>
          </tr>
           <tr> 
            <td class='bline' height="26" style="padding-left:10px;"><font color='green'>所获学历:</font></td>
            <td class='bline'><input name="xueli" type="text" id="xueli" size="30" value="" class="iptxt" /></td>
           </tr>  
           <tr> 
            <td class='bline' height="26" style="padding-left:10px;"><font color='green'>第一自定义标题:</font></td>
            <td class='bline'><input name="firstcustomtitle" type="text" id="firstcustomtitle" size="30" value="" class="iptxt" /></td>
           </tr>           
           <tr> 
            <td class='bline' height="26" style="padding-left:10px;"><font color='green'>第二自定义标题:</font></td>
            <td class='bline'><input name="secondcustomtitle" type="text" id="secondcustomtitle" size="30" value="" class="iptxt" /></td>
           </tr>                         
          <!--自定义字段结束-->

3) /后台/templets/catalog_edit.htm 约 283行以下 增加 
 <!--自定义字段开始-->
          <tr> 
            <td class='bline' height="26" style="padding-left:10px;"><font color='green'>自定义内容:</font></td>
            <td class='bline'><input name="customcontent" type="text" id="customcontent" size="100" value="<?php echo $myrow['customcontent']?>" class="iptxt" /></td>
          </tr>
           <tr> 
            <td class='bline' height="26" style="padding-left:10px;"><font color='green'>所获学历:</font></td>
            <td class='bline'><input name="xueli" type="text" id="xueli" size="100" value="<?php echo $myrow['xueli']?>" class="iptxt" /></td>
          </tr>         
            <tr> 
            <td class='bline' height="26" style="padding-left:10px;"><font color='green'>第一自定义标题:</font></td>
            <td class='bline'><input name="firstcustomtitle" type="text" id="firstcustomtitle" size="30" value="<?php echo $myrow['firstcustomtitle']?>" class="iptxt" /></td>
           </tr>  
           <tr> 
            <td class='bline' height="26" style="padding-left:10px;"><font color='green'>第二自定义标题:</font></td>
            <td class='bline'><input name="secondcustomtitle" type="text" id="secondcustomtitle" size="30" value="<?php echo $myrow['secondcustomtitle']?>" class="iptxt" /></td>
           </tr>  
          <!--自定义字段结束-->

4) 后台/catalog_add.php 约 65行改为
 $queryTemplate = "INSERT INTO `#@__arctype`(reid,topid,sortrank,typename,typedir,isdefault,defaultname,issend,channeltype,    tempindex,templist,temparticle,modname,namerule,namerule2,ispart,corank,description,keywords,seotitle,moresite,siteurl,sitepath,ishidden,`cross`,`crossid`,`content`,`smalltypes`,`customcontent`,`xueli`,`firstcustomtitle`,`secondcustomtitle`)
    VALUES('~reid~','~topid~','~rank~','~typename~','~typedir~','$isdefault','$defaultname','$issend','$channeltype',    '$tempindex','$templist','$temparticle','default','$namerule','$namerule2','0','0','','','~typename~','0','','','0','0','0','','','$customcontent','$xueli','$firstcustomtitle','$secondcustomtitle')";

5) 
后台/catalog_add.php 约 229行改为
$in_query = "INSERT INTO `#@__arctype`(reid,topid,sortrank,typename,typedir,isdefault,defaultname,issend,channeltype,
    tempindex,templist,temparticle,modname,namerule,namerule2,    ispart,corank,description,keywords,seotitle,moresite,siteurl,sitepath,ishidden,`cross`,`crossid`,`content`,`smalltypes`,`customcontent`,`xueli`,`firstcustomtitle`,`secondcustomtitle`)
    VALUES('$reid','$topid','$sortrank','$typename','$typedir','$isdefault','$defaultname','$issend','$channeltype',
    '$tempindex','$templist','$temparticle','default','$namerule','$namerule2',    '$ispart','$corank','$description','$keywords','$seotitle','$moresite','$siteurl','$sitepath','$ishidden','$cross','$crossid','$content','$smalltypes','$customcontent','$xueli','$firstcustomtitle','$secondcustomtitle')";

6) 后台
/catalog_edit.php 约 62行后增加  
     `customcontent`='$customcontent',   
     `xueli`='$xueli',    
     `firstcustomtitle`='$firstcustomtitle',   
     `secondcustomtitle`='$secondcustomtitle' 
7) include/taglib/channel.lib.php 约 78行左右 以下改为
 if($type=='top')
    {
        $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,
    customcontent, xueli,firstcustomtitle,secondcustomtitle 
          From `#@__arctype` WHERE reid=0 And ishidden<>1 order by sortrank asc limit 0, $line ";
    }
    else if($type=='son')
    {
        if($typeid==0) return '';
        $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,
    customcontent, xueli,firstcustomtitle,secondcustomtitle 
          From `#@__arctype` WHERE reid='$typeid' And ishidden<>1 order by sortrank asc limit 0, $line ";
    }
    else if($type=='self')
    {
        if($reid==0) return '';
        $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,
    customcontent, xueli,firstcustomtitle,secondcustomtitle 
            FROM `#@__arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line ";
    }
8) include/taglib/channel.lib.php 约 115行左右 以下改为
if($type=='son' && $reid!=0 && $totalRow==0)
    {
        $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,
    customcontent, xueli,firstcustomtitle,secondcustomtitle 
            FROM `#@__arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line ";
        $dsql->SetQuery($sql);
      $dsql->Execute();
    }

9) /include/taglib/type.lib.php  约 43行左右 以下改为
     $row = $dsql->GetOne("SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,
    customcontent, xueli,firstcustomtitle,secondcustomtitle,content   FROM `#@__arctype` WHERE id='$typeid' ");
 

普通分类: