為了在普通文章模型上實現多條件篩選功能.需要在后臺增加虛擬的自定義字段,字段的值沒有使用價值,只是為了實現特殊功能.
比如在后臺內容模型管理中,普通文章模型,新增加了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 這里面.修改方法一致.