当前位置 : 主页 > 网站建设 > 正文

DedeCMS搜索支持自增函数autoindex

原创

重庆seo2016-05-18 08:33:00阅读()php开发dedecmsA+ / A-

DedeCMS搜索支持自增函数autoindex

       [field:global.autoindex/]这个自增函数是非常常用的函数,用在不同的标签下,产生的数组不一样,用dedecms做网页设计的时候根据实际需要选用。常用的有网站导航、隔行换色、TAG标签随机样式、列表页提交内容页表单、商品列表添加多个商品到购物车等。

dede搜索调用自定义字段自增[field:global.autoindex/]

[field:global.autoindex/]在不同标签下产生数组

arclist 标签下使用 [field:global.autoindex/] 默认从1开始
channel 标签下使用 [field:global.autoindex/] 默认从0开始
channelartlist 标签下使用 {dede:global.itemindex/} 默认从1开始
arclist 从0开始[field:global name=autoindex runphp="yes"]@me=@me-1;[/field:global]
channel 从1开始[field:global name=autoindex runphp="yes"]@me=@me+1;[/field:global][field:typename/]
channelartlist 从0开始{dede:global name=itemindex runphp='yes'}@me=@me-1;{/dede:global}
channelartlist 标签下使用 {dede:global name='itemindex' runphp='yes'}@me;{/dede:global}

       dedecms的搜索页面不支持自增函数[field:global.autoindex/],这可蛋疼了,自己研究了一下分享给站长们。

       打开/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));
}

       这样就能让搜索页支持{dede:arclist}{/dede:arclist}标签,就能解决[field:global.autoindex/]失效的问题,{dede:arclist}标签很灵活,能用在列表或者首页、在列表页相当于{dede:list},也支持分页,但是自定义字段需要动一下手。

搜索页面调用自定义字段前台HTML源代码

{dede:arclist row='20' addfields='自定义字段' channelid='该字段所在的频道模型ID'}
<div class="p_[field:global.autoindex/]">[field:title/]</div>
{/dede:arclist}

       dede搜索页另外一种增加自定义字段的方法参考文章《dedecms搜索功能增加自定义字段》。

搜索页面支持单独栏目搜索功能HTML源代码

    <div 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>
    </div><!-- //search -->

    扩展阅读

    本文地址:https://www.vi586.com/web/277.html
    版权声明:原创文章,版权归重庆SEO吖七所有,欢迎分享本文,支持原创,转载请保留出处

    赞(17)