[field:global.autoindex/]這個(gè)自增函數(shù)是非常常用的函數(shù),用在不同的標(biāo)簽下,產(chǎn)生的數(shù)組不一樣,用dedecms做網(wǎng)頁(yè)設(shè)計(jì)的時(shí)候根據(jù)實(shí)際需要選用。常用的有網(wǎng)站導(dǎo)航、隔行換色、TAG標(biāo)簽隨機(jī)樣式、列表頁(yè)提交內(nèi)容頁(yè)表單、商品列表添加多個(gè)商品到購(gòu)物車(chē)等。
[field:global.autoindex/]在不同標(biāo)簽下產(chǎn)生數(shù)組
arclist 標(biāo)簽下使用 [field:global.autoindex/] 默認(rèn)從1開(kāi)始 channel 標(biāo)簽下使用 [field:global.autoindex/] 默認(rèn)從0開(kāi)始 channelartlist 標(biāo)簽下使用 {dede:global.itemindex/} 默認(rèn)從1開(kāi)始 arclist 從0開(kāi)始[field:global name=autoindex runphp="yes"]@me=@me-1;[/field:global] channel 從1開(kāi)始[field:global name=autoindex runphp="yes"]@me=@me+1;[/field:global][field:typename/] channelartlist 從0開(kāi)始{dede:global name=itemindex runphp='yes'}@me=@me-1;{/dede:global} channelartlist 標(biāo)簽下使用 {dede:global name='itemindex' runphp='yes'}@me;{/dede:global}
dedecms的搜索頁(yè)面不支持自增函數(shù)[field:global.autoindex/],這可蛋疼了,自己研究了一下分享給站長(zhǎng)們。
打開(kāi)/include/arc.searchview.class/php,在頂部找到
require_once(DEDEINC."/taglib/hotwords.lib.php");
在下面添加
require_once(DEDEINC."/taglib/arclist.lib.php");
找到
else if($tagname=="hotwords") { $this->dtp->Assign($tagid,lib_hotwords($ctag,$this)); }
在下面添加
else if($tagname=="arclist") { $this->dtp->Assign($tagid,lib_arclist($ctag,$this)); }
這樣就能讓搜索頁(yè)支持{dede:arclist}{/dede:arclist}標(biāo)簽,就能解決[field:global.autoindex/]失效的問(wèn)題,{dede:arclist}標(biāo)簽很靈活,能用在列表或者首頁(yè)、在列表頁(yè)相當(dāng)于{dede:list},也支持分頁(yè),但是自定義字段需要?jiǎng)右幌率帧?/p>
搜索頁(yè)面調(diào)用自定義字段前臺(tái)HTML源代碼
{dede:arclist row='20' addfields='自定義字段' channelid='該字段所在的頻道模型ID'} <p class="p_[field:global.autoindex/]">[field:title/]</p> {/dede:arclist}
dede搜索頁(yè)另外一種增加自定義字段的方法參考文章《dedecms搜索功能增加自定義字段》。
搜索頁(yè)面支持單獨(dú)欄目搜索功能HTML源代碼
<p class="search"> <form name="formsearch" action="{dede:global.cfg_cmsurl/}/plus/search.php"> <input type="hidden" name="kwtype" value="0" /> <select name="searchtype" class="search-option" id="search-option"> <option value="title" selected='1'>All</option> {dede:channelartlist typeid='2' } {dede:type} <option value='[field:id/]'>[field:typename/]</option>{/dede:type} {dede:channel type='son' noself='yes'} <option value='[field:id/]'>-[field:typename/]</option> {/dede:channel} {/dede:channelartlist} </select> <input name="q" type="text" class="search-keyword" id="search-keyword" value="Part Cord..." onfocus="if(this.value=='Part Cord...'){this.value='';}" onblur="if(this.value==''){this.value='Part Cord...';}" /> <button type="submit" class="search-submit"></button> </form> </p><!-- //search -->