织梦园模板网提供云优cms模板,pbootcms模板,Wordpress主题模板等各类企业新闻资讯网站模板下载服务。织梦园网站模板交流群
用户名:
密码:
注册
注册后享受折扣价

织梦dedecms 在会员中心或后台 隐藏特定字段,部分或个别自定义字段的方法

织梦园模板 / 2019-07-15 / 收藏

为了在普通文章模型上实现多条件筛选功能.需要在后台增加虚拟的自定义字段,字段的值没有使用价值,只是为了实现特殊功能.

比如在后台内容模型管理中,普通文章模型,新增加了n个字段.但在发表文档时,不希望直接显示个别字段,比如商品价格从高到低排序字段myorder字段. 这个字段虽然在后台有定义.但他的值是没有必要在后台固定的,因为在前台点击按价格排序时,程序会执行orderby  price asc 的sql语句.与这个字段本身的值无关.

所以,前台就没有必要显示这个字段.会员中心如果想过滤掉这个字段,需要修改member\inc\inc_archives_functions.PHP中的 PrintAutoFieldsAdd及PrintAutoFieldsEdit函数.把这句

foreach($dtp->CTags as $tid=>$ctag)  
     {  
         if($loadtype!='autofield'  
         || ($loadtype=='autofield' && $ctag->GetAtt('autofield')==1) )  
         {  
             $dede_addonfields .= ( $dede_addonfields=="" ? $ctag->GetName().",".$ctag->GetAtt('type') : ";".$ctag->GetName().",".$ctag->GetAtt('type') );  
             echo  GetFormItemA($ctag);  
         }  
     }  

对比修改为下面这句即可.

foreach($dtp->CTags as $tid=>$ctag){  
if($ctag->GetName()=='myorder'||$ctag->GetName()=='mystate'){  
unset($ctag);//如果字段名为myorder或mystate,则删除字段所在的数组.并跳过下面的执行.  
}else{  
//否则,继续向下执行.  
         if($loadtype!='autofield' ||  $ctag->GetAtt('autofield')==1 )  
         {  
             $dede_addonfields .= ( $dede_addonfields=="" ? $ctag->GetName().",".$ctag->GetAtt('type') : ";".$ctag->GetName().",".$ctag->GetAtt('type') );  
             $addonfieldsname .= ",".$ctag->GetName();  
             if ($isprint) echo  GetFormItemA($ctag);  
         }  
 }  
     }   

网站后台修改文件在dede\inc\inc_archives_functions.php 这里面.修改方法一致.

相关织梦教程

收缩