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

来源:互联网 发布:剑三成男捏脸数据花哥 编辑:程序博客网 时间:2024/06/05 03:12

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

比如在后台内容模型管理中,普通文章模型,新增加了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 这里面.修改方法一致.

0 0
原创粉丝点击