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

首頁 > CMS > 織夢DEDE > 正文

DedeCMS自增函數autoindex/itemindex用法全解析

2024-07-12 08:51:01
字體:
來源:轉載
供稿:網友
這篇文章主要為大家詳細介紹了DedeCMS自增函數autoindex/itemindex用法全解析,具有一定的參考價值,感興趣的小伙伴們可以參考一下,有需要的朋友可以收藏方便以后借鑒。

DedeCMS自增函數autoindex/itemindex用法全解析:

在使用DedeCMS建站的過程中,首頁或者列表頁的模版會涉及到調用欄目或者子欄目的問題,在調用欄目的時候會在第一個欄目鏈接中加特別的屬性,這里就要用到DedeCMS自帶的自增函數[field:global name=autoindex/]和[field:global name=itemindex/],余斗今天就來說說這個[field:global name=autoindex/]和[field:global name=itemindex/]自增函數的一些用法與擴展。

基本用法

autoindex與itemindex都是中都是用@me來表示計數開始,而類似@me+1則可以指定數字開始,在不同的標簽中,他們的起始值是不同的:

channelartlist 標簽下使用 {dede:global name='itemindex' runphp='yes'}@me;{/dede:global} 是從0開始自增1

channelartlist 標簽下使用 {dede:global.itemindex/} 默認從1開始

arclist 標簽下使用 [field:global.autoindex/] 默認從1開始

channel 標簽下使用 [field:global.autoindex/] 默認從0開始

而如果想要改變起始值則按照以下方式調用:

從0開始[field:global name=autoindex runphp="yes"]@me=@me-1;[/field:global]

從1開始[field:global name=autoindex runphp="yes"]@me=@me+1;[/field:global]

其中,@me=@me±1就能實現對應的起始值,這里自己根據需要修改即可。

擴展用法

起始值加5開始自增計數

 

[field:global name=autoindex runphp="yes"]@me=@me+5;[/field:global]

 

如果被2整除則輸出豎線否則為空

 

[field:global name=autoindex runphp="yes"](@me%2==0)? @me="|":@me="";[/field:global]

 

如果不等于8輸出豎線否則為空,即為8的時候不打印豎線

 

[field:global name=autoindex runphp="yes"](@me!=8)? @me="|":@me="";[/field:global]

 

列表每5行有帶劃線

 

[field:global runphp='yes' name=autoindex]

                      $a="<li>";

                      $c="<li class='line'>";

                      if ((@me % 5) == 0) @me = $c;

                      else @me = $a;

  [/field:global]

 

在第5行和第10行加廣告,其他行為空

 

[field:global runphp='yes' name=autoindex]

                      $a="<div class='box'>";

                      $b="廣告1";

                      $c="</div>";

                      $d="廣告2";

                      $e="";

                      if (@me == 5) @me = $a.$b.$c;

                            else if (@me == 10) @me = $a.$d.$c;

                      else @me = $e;

  [/field:global]

 

第一行樣式為class="check",其他行按行數類名字后面id="life_channe1"的數字1實現自增

 

<li><a href="[field:typeurl/] " [field:global name='autoindex'runphp='yes']if(@me==0){@me='class="check"';}else{@me='id="life_channe'.@me.'" goto="life_channe'.@me.'"';}[/field:global]>[field:typename/]</a></li>

 

Div中id名字后面的數字從0開始自增,判斷如果是第一行則加style="display:none;"屬性,其他行為空

 

<div id="HomeCon2_1_{dede:global name=itemindex runphp='yes'}@me=@me-1;{/dede:global}"class="HomeCon2_1_1" {dede:global name='itemindex' runphp='yes'}@me=(@me==1)?'':'style="display:none;"';{/dede:global} >

 

對autoindex/itemindex使用自定義函數

先在include/extend.fun.php里添加自定義函數

 

function MyPosition($p){

$positionArr=array(275,330,380,435,495,547);

return $positionArr[$p];

 

模版中調用方法為:

 

{dede:channel type='son' typeid='13' row='6' noself='yes'}

<!-----側欄菜單------------------> 

<div id='pdv_16795' class='pdv_class' title='' style="width:71px;height:20px;top:[field:global.autoindex function='MyPosition(@me)'/]px;left:136px; z-index:17">

<div style="FONT-FAMILY: SimSun; COLOR: #fecd2e; FONT-SIZE: 15px; fon-weight: bold"><a style="FONT-FAMILY: SimSun; COLOR: #fecd2e; FONT-SIZE: 15px; fon-weight: bold" href="[field:typeurl/]" target=_blank><strong>[field:typename/]</strong></a></div>

</div>

{/dede:channel}

 

織夢默認的搜索頁不支持autoindex標簽,需要修改核心文件增加支持

找到文件:include/arc.searchview.class.php

里面找到代碼(大概在709行):

 

DedeCMS自增函數autoindex/itemindex用法全解析

 

$this->dtp2->LoadSource($innertext);

 

修改為:

 

$this->dtp2->LoadSource($innertext);

$GLOBALS['autoindex'] = 0;

 

找到代碼(大概在722行):

 

DedeCMS自增函數autoindex/itemindex用法全解析

 

if($row = $this->dsql->GetArray("al"))

                                {

 

修改為

 

if($row = $this->dsql->GetArray("al"))

                                {

                                        $GLOBALS['autoindex']++;

                                        $ids[$row['id']] = $row['id'];

 

以上就是余斗整理的autoindex/itemindex'用法與擴展,希望能幫到大家。本文轉自網絡,如有侵權,請聯系本站及時刪除。

以上就是DedeCMS自增函數autoindex/itemindex用法全解析的全部內容,希望對大家的學習和解決疑問有所幫助,也希望大家多多支持武林網。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 弥勒县| 兴安县| 宜丰县| 正安县| 汽车| 台东县| 盈江县| 怀来县| 衡阳市| 晴隆县| 朝阳市| 丽水市| 邳州市| 新化县| 汤阴县| 博野县| 丹寨县| 桦川县| 金沙县| 长泰县| 竹北市| 高密市| 峨眉山市| 铜陵市| 斗六市| 海丰县| 巴林右旗| 洪雅县| 甘德县| 镇原县| 图木舒克市| 哈巴河县| 岚皋县| 中宁县| 梁平县| 淮安市| 信宜市| 巴马| 财经| 满洲里市| 舒兰市|