国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

列表頁(list.var)判斷推薦、頭條、置頂,并加(推薦、頭條、置頂圖)

2024-04-25 20:54:58
字體:
來源:轉載
供稿:網友
說明:
1、首先注意開啟置頂:后臺 》 系統 》 系統參數設置 》 信息設置 》 信息置頂設置 ,選擇 欄目/標簽置頂
2、使用的代碼
①、調用幾級推薦、頭條、置頂 ,如下調用的都是一級的推薦、頭條、置頂 
if(!empty($bqr[titlepic])) //圖片 
if($bqr[isgood]==1) //推薦 
if($r[firsttitle]==1) //頭條 
if($r[istop]==1) //置頂 
if($bqr[isgood]==1&&$bqr[firsttitle]==1&&$bqr[istop]==1) //置頂-頭條-推薦 (組合使用) 

②、調用全部的推薦、頭條、置頂(即:把“==1”修改為“>0”)
if(!empty($bqr[titlepic])) //圖片 
if($bqr[isgood]>0) //推薦 
if($r[firsttitle]>0) //頭條 
if($r[istop]>0) //置頂 
if($bqr[isgood]>0&&$bqr[firsttitle]>0&&$bqr[istop]>0) //置頂-頭條-推薦 (組合使用) 
---------------------------------------------------------------------------------------------
方法1、判斷各自的(有兩個或兩個以上的屬性,也只顯示一個屬性),即:只顯示一個圖

注釋:如一個信息有“推薦”和“頭條”兩個屬性,下面的代碼也只能讓其顯示一個屬性(那個屬性在前就先顯示那個)
<?=$newimg?>可以是圖片 $newimg="<img src='dg2/e/data/images/saypl.gif' />"; 

舉例:

$r[title]=esub($r[title],27,'...');
$newimg=""; 
if($r[istop]==1)
{
$newimg="<font color=red>[頂]</font>";
}
elseif($r[isgood]==1)  
{
$newimg="<font color=red>[薦]</font>";
}
elseif($r[firsttitle]==1)  
{
$newimg="<font color=red>[頭]</font>";
}

$listtemp='

<li>【'.$class_r[$r[classid]]['classname'].' 】【[!--this.classname--]】'.$newimg.' <a href="[!--titleurl--]" title="[!--oldtitle--]">[!--title--]</a> <span>[!--newstime--]</span></li>

';

注釋:$newimg=""; newimg為空     
      if($r[istop]==1){$newimg="<font color=red>[頂]</font>";     當istop=1時,newimg顯示“[頂]”

php部分還可以這樣寫判斷  格式:if -> elseif -> else   意思:“判斷” 或 “2判讀” 否則  “為空”
  實際上就是把$newimg=""; 用else放到了最下面

實例:
$r[title]=esub($r[title],27,'...');
if($r[istop]==1)
{
$newimg="<font color=red>[頂]</font>";
}
elseif($r[isgood]==1)  
{
$newimg="<font color=red>[薦]</font>";
}
elseif($r[firsttitle]==1)  
{
$newimg="<font color=red>[頭]</font>";
}
else
{
$newimg="";
}
$listtemp='

<li>【'.$class_r[$r[classid]]['classname'].' 】【[!--this.classname--]】'.$newimg.' <a href="[!--titleurl--]" title="[!--oldtitle--]">[!--title--]</a> <span>[!--newstime--]</span></li>

';


-------------------------------------------------------------------------------
方法2、判斷各自的(有兩個或兩個以上的屬性,可顯示多個屬性),即:可顯示多個圖。在上面代碼的基礎上組合了個“兩個的屬性”,即:一個信息兩張圖
      
注釋:如一個信息有“推薦”和“頭條”兩個屬性,在上面的代碼基礎上加了一個判斷的語句把“推薦”和“頭條”組合在一起可以顯示雙屬性的屬性語句。
即:一條信息同時顯示“推薦”和“頭條”兩個屬性
<?=$newimg?>可以是圖片 $newimg="<img src='dg2/e/data/images/saypl.gif' />";


舉例:
$r[title]=esub($r[title],27,'...');
$newimg=""; 
if($r[isgood]==1&&$r[firsttitle]==1) 
{
$newimg="<font color=red>[推薦]</font> &nbsp;<font color=red>[頭條]</font>";   
}
elseif($r[isgood]==1)  
{
$newimg="<font color=red>[推薦]</font>";
}
elseif($r[firsttitle]==1)  
{
$newimg="<font color=red>[頭條]</font>";
}
$listtemp='

<li>【'.$class_r[$r[classid]]['classname'].' 】【[!--this.classname--]】'.$newimg.' <a href="[!--titleurl--]" title="[!--oldtitle--]">[!--title--]</a> <span>[!--newstime--]</span></li>

';

注釋:$newimg=""; newimg為空     
      if($r[istop]==1){$newimg="<font color=red>[頂]</font>";     當istop=1時,newimg顯示“[頂]”

php部分還可以這樣寫判斷  格式:if -> elseif -> else   意思:“判斷” 或 “2判讀” 否則  “為空”
  實際上就是把$newimg=""; 用else放到了最下面

實例:同上
------------------------------------------------------------------------------------------------------------------

方法3、判斷各自的,(有兩個或兩個以上的屬性,可顯示多個屬性),即:可顯示多個圖。各自加各自的圖,即:每個屬性上多能加多張圖
<?=$newimg?>可以是圖片 $newimg="<img src='dg2/e/data/images/saypl.gif' />";

$r[title]=esub($r[title],27,'...');
$newimg="";
$top="";
$good="";
$ttitle="";
if(!empty($r[titlepic])) 

$newimg="<font color=red>[圖片]</font>"; 

if($r[istop]==1) 

$top = "<font color=red>[置頂]</font>"; 

if($r[isgood]==1) 

$good = "<font color=red>[推薦]</font>"; 

if($r[firsttitle]==1) 

$ttitle = "<font color=red>[頭條]</font>"; 

$listtemp='

<li>【'.$class_r[$r[classid]]['classname'].' 】【[!--this.classname--]】&nbsp;'.$newimg.' &nbsp;'.$top.'&nbsp;'.$good.'&nbsp;'.$ttitle.' <a href="[!--titleurl--]" title="[!--oldtitle--]">[!--title--]</a> <span>[!--newstime--]</span></li>

';


注釋:$newimg="";、$top="";、$good="";、$ttitle=""; 各自為空     
      [titlepic]、[istop]==1、[isgood]==1、[firsttitle]==1      當=1時,各自顯示各自的圖
     
php部分還可以這樣寫判斷  格式:if ->  else   意思:“判斷”  否則  “為空”
  實際上就是把$newimg=""; 用else放到了最下面

實例:
$r[title]=esub($r[title],27,'...');
if(!empty($r[titlepic])) 

$newimg="<font color=red>[圖片]</font>"; 

else
{
$newimg='';
}
if($r[istop]==1) 

$top = "<font color=red>[置頂]</font>"; 

else
{
$top='';

if($r[isgood]==1) 

$good = "<font color=red>[推薦]</font>"; 

else
{
$good='';

if($r[firsttitle]==1) 

$ttitle = "<font color=red>[頭條]</font>"; 
}
else
{
$ttitle='';
}  
$listtemp='

<li>【'.$class_r[$r[classid]]['classname'].' 】【[!--this.classname--]】&nbsp;'.$newimg.' &nbsp;'.$top.'&nbsp;'.$good.'&nbsp;'.$ttitle.' <a href="[!--titleurl--]" title="[!--oldtitle--]">[!--title--]</a> <span>[!--newstime--]</span></li>

';



---------------------------------------實例-----------------------------------------------

圖片、置頂、一級二級推薦、一級二級頭條

php部分還可以這樣寫判斷  格式:if -> elseif -> else   意思:“判斷” 或 “2判讀” 否則  “為空”
  實際上就是把$newimg=""; 用else放到了最下面

<br>------------------方法1----------------------<br>
$r[title]=esub($r[title],27,'...');
$newimg="";
$top="";
$good=""; 
$ttitle="";
if(!empty($r[titlepic])) 

$newimg="<font color=red>[圖片]</font>"; 

if($r[istop]==1) 

$top = "<font color=red>[置頂]</font>"; 

if($r[isgood]==1) 

$good = "<font color=red>[推薦]</font>"; 

elseif($r[isgood]==2)  
{
$good="<font color=red>[推薦2]</font>";
}
if($r[firsttitle]==1) 

$ttitle = "<font color=red>[頭條]</font>"; 

elseif($r[firsttitle]==2)  
{
$ttitle="<font color=red>[頭條2]</font>";
}
$listtemp='

<li>【'.$class_r[$r[classid]]['classname'].' 】【[!--this.classname--]】&nbsp;'.$newimg.' &nbsp;'.$top.'&nbsp;'.$good.'&nbsp;'.$ttitle.' <a href="[!--titleurl--]" title="[!--oldtitle--]">[!--title--]</a> <span>[!--newstime--]</span></li>

';


方法1:PHP部分的格式:為空 -> if -> elseif


<br>------------------方法2----------------------<br>
$r[title]=esub($r[title],27,'...');
if(!empty($r[titlepic])) 

$newimg="<font color=red>[圖片]</font>"; 

else
{
$newimg='';

if($r[istop]==1) 

$top = "<font color=red>[置頂]</font>"; 

else
{
$top='';

if($r[isgood]==1) 

$good = "<font color=red>[推薦]</font>"; 

elseif($r[isgood]==2)  
{
$good="<font color=red>[推薦2]</font>";
}
else
{
$good='';

if($r[firsttitle]==1) 

$ttitle = "<font color=red>[頭條]</font>"; 

elseif($r[firsttitle]==2)  
{
$ttitle="<font color=red>[頭條2]</font>";
}
else
{
$ttitle='';

$listtemp='

<li>【'.$class_r[$r[classid]]['classname'].' 】【[!--this.classname--]】&nbsp;'.$newimg.' &nbsp;'.$top.'&nbsp;'.$good.'&nbsp;'.$ttitle.' <a href="[!--titleurl--]" title="[!--oldtitle--]">[!--title--]</a> <span>[!--newstime--]</span></li>

';


方法2:PHP部分的格式:if -> elseif -> else
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 潞城市| 大邑县| 曲松县| 梅州市| 都江堰市| 北安市| 青岛市| 通州市| 怀宁县| 正阳县| 同德县| 商河县| 特克斯县| 洪湖市| 泰来县| 芦溪县| 丽水市| 德阳市| 上林县| 陆丰市| 会昌县| 玛纳斯县| 泰和县| 凉城县| 溆浦县| 淮北市| 弥渡县| 民权县| 竹北市| 饶阳县| 平江县| 黔东| 泗洪县| 浏阳市| 稻城县| 银川市| 嘉祥县| 河间市| 永丰县| 永昌县| 旬阳县|