dedecms中autoindex

在DedeCMS中,AutoIndex是一个非常有用的功能,它可以帮助我们轻松地生成网站的自动目录。这对于那些需要展示大量文件或者目录的网站来说,无疑是一个福音。今天,我们就来详细探讨一下DedeCMS中的AutoIndex功能,看看它是如何工作的,以及如何利用它来优化我们的网站。

AutoIndex简介

AutoIndex,顾名思义,就是自动生成目录的意思。在DedeCMS中,它可以帮助我们自动生成网站的文件目录,使得访问者可以方便地浏览网站中的文件。这对于大型网站来说,尤其有用,因为它可以大大提高网站的浏览体验。

AutoIndex的工作原理

AutoIndex的工作原理非常简单。当用户访问一个设置了AutoIndex功能的目录时,DedeCMS会自动扫描该目录下的所有文件和子目录,并将它们以列表的形式展示给用户。

步骤 描述
1. 用户访问设置了AutoIndex功能的目录
2. DedeCMS扫描目录下的所有文件和子目录
3. 将扫描到的文件和目录以列表形式展示给用户

如何启用AutoIndex

要启用DedeCMS中的AutoIndex功能,我们需要进行以下操作:

1. 登录到DedeCMS后台。

2. 进入系统 > 系统参数

3. 在文件参数中找到启用目录列表,将其设置为开启

4. 保存设置。

AutoIndex的应用场景

1. 文件分享网站

对于文件分享网站来说,AutoIndex功能可以帮助用户方便地浏览和下载文件。例如,一个音乐分享网站可以使用AutoIndex来展示所有音乐文件的目录。

2. 图片展示网站

图片展示网站也可以使用AutoIndex来展示图片的目录。这样,用户可以轻松地浏览和查看所有图片。

3. 大型网站

对于大型网站来说,AutoIndex功能可以帮助用户快速找到他们想要的文件或目录。例如,一个公司网站可以使用AutoIndex来展示所有产品的目录。

AutoIndex的优化

虽然AutoIndex功能非常方便,但有时候也需要进行一些优化,以提高用户体验。

1. 文件排序

默认情况下,DedeCMS会按照文件名来排序。但有时候,我们可能需要按照文件的修改时间或者文件大小来排序。这时,我们可以在DedeCMS后台的系统参数中设置文件排序方式。

2. 文件展示方式

DedeCMS默认以列表形式展示文件和目录。但有时候,我们可能需要以表格形式展示,或者只展示文件名。这时,我们可以在DedeCMS后台的系统参数中设置文件展示方式。

3. 文件访问权限

为了保护网站的安全,我们可能需要限制某些目录或文件的访问权限。这时,我们可以在DedeCMS后台的系统参数中设置文件访问权限。

总结

DedeCMS中的AutoIndex功能是一个非常实用的功能,它可以帮助我们轻松地生成网站的自动目录。通过了解AutoIndex的工作原理和应用场景,我们可以更好地利用它来优化我们的网站。希望本文能够帮助到您!

dedecms 列表点击加载更多读取数据库内容怎么实现

使用方法:

1、加载是用AJAX,需要先引用jQuery

2、模板在arcajax.php第二十八行请自行按需修改

3、arcajax.php放到plus目录下

HTML和js代码:

<divid=”loading27″>加载中</div>

<ahref=”javascript:;”id=”getMore”pnum=”2″class=”index-morebgwmt15″>浏览更多案例……</a>

<scripttype=”text/javascript”>

$(“#getMore”).click(function(){

var_this=$(this),

pnum=_this.attr(“pnum”),//分页码

typeid=1;//栏目ID

if(pnum==0){

returnfalse;

}

$(“#loading27”).show();

$.ajax({

url:'/plus/arcajax.php',

data:{typeid:typeid,pnum:pnum},

success:function(data){

if(data!=''){

$(“.index-list”).append(data);//数据显示到页面

_this.attr(“pnum”,Number(pnum)+1);//分页+1

}else{

_this.text(“没有更多的数据”);

_this.attr(“pnum”,0)

}

$(“#loading27”).hide();

}

})

returnfalse;

})

</script>

PHP代码(arcajax.php):

<?php

require_once(dirname(__FILE__).”/../include/common.inc.php”);

require_once(DEDEINC.'/channelunit.class.php');

require_once(DEDEINC.'/taglib/arcpagelist.lib.php');

$pnum=empty($pnum)?0:intval(preg_replace(“/[^\d]/”,'',$pnum));

$typeid=empty($typeid)?0:intval(preg_replace(“/[^\d]/”,'',$typeid));

if($typeid==0||$pnum==0)die(“RequestError!”);

if($typeid>0)

{

$titlelen=AttDef($titlelen,30);

$infolen=AttDef($infolen,160);

$imgwidth=AttDef($imgwidth,120);

$imgheight=AttDef($imgheight,120);

$listtype=AttDef($listtype,'all');

$arcid=AttDef($arcid,0);

$channelid=AttDef($channelid,0);

$orderby=AttDef($orderby,'default');

$orderWay=AttDef($order,'desc');

$subday=AttDef($subday,0);

$line=$row;

$artlist='';

//通过页面及总数解析当前页面数据范围

$strnum=($pnum-1)*12;

$limitsql=”LIMIT$strnum,12″;

$innertext='<li[field:globalname=”autoindex”runphp=”yes”]if(@me%3==0)@me=\'class=”mrnone”\';else@me=””;[/field:global]>

<div><ahref=”[field:arcurl/]”title=”[field:title/]”><imgsrc=”[field:litpic/]”width=”278″height=”245″></a></div>

<h3><ahref=”[field:arcurl/]”title=”[field:title/]”>[field:title/]</a></h3>

<p>[field:descriptionfunction=”cn_substr(@me,150)”/]</p>

<spanclass=”more”><ahref=”[field:arcurl/]”>浏览案例</a></span>

</li>';//模板

//处理列表内容项

$query=”SELECTarc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,

tp.moresite,tp.siteurl,tp.sitepathFROM`#@__archives`arcLEFTJOIN`#@__arctype`tpONarc.typeid=tp.id

WHEREarc.typeidIN(“.GetSonIds($typeid).”)ORDERBYarc.sortrankdesc$limitsql”;

$dsql->SetQuery($query);

$dsql->Execute('al');

$dtp2=newDedeTagParse();

$dtp2->SetNameSpace('field','[',']');

$dtp2->LoadString($innertext);

$GLOBALS['autoindex']=0;

$ids=array();

for($i=0;$i<12;$i++)

{

for($j=0;$j<1;$j++)

{

if($row=$dsql->GetArray(“al”))

{

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

//处理一些特殊字段

$row['info']=$row['infos']=cn_substr($row['description'],$infolen);

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

if($row['corank']>0&&$row['arcrank']==0)

{

$row['arcrank']=$row['corank'];

}

$row['filename']=$row['arcurl']=GetFileUrl($row['id'],$row['typeid'],$row['senddate'],$row['title'],$row['ismake'],

$row['arcrank'],$row['namerule'],$row['typedir'],$row['money'],$row['filename'],$row['moresite'],$row['siteurl'],$row['sitepath']);

$row['typeurl']=GetTypeUrl($row['typeid'],$row['typedir'],$row['isdefault'],$row['defaultname'],$row['ispart'],

$row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']);

if($row['litpic']=='-'||$row['litpic']=='')

{

$row['litpic']=$GLOBALS['cfg_cmspath'].'/images/defaultpic.gif';

}

if(!preg_match(“#^http:\/\/#”,$row['litpic'])&&$GLOBALS['cfg_multi_site']=='Y')

{

$row['litpic']=$GLOBALS['cfg_mainsite'].$row['litpic'];

}

$row['picname']=$row['litpic'];

$row['stime']=GetDateMK($row['pubdate']);

$row['typelink']=”<ahref='”.$row['typeurl'].”'>”.$row['typename'].”</a>”;

$row['image']=”<imgsrc='”.$row['picname'].”'border='0'width='$imgwidth'height='$imgheight'alt='”.preg_replace(“#['><]#”,””,$row['title']).”'>”;

$row['imglink']=”<ahref='”.$row['filename'].”'>”.$row['image'].”</a>”;

$row['fulltitle']=$row['title'];

$row['title']=cn_substr($row['title'],$titlelen);

if($row['color']!='')$row['title']=”<fontcolor='”.$row['color'].”'>”.$row['title'].”</font>”;

if(preg_match('#b#',$row['flag']))$row['title']=”<strong>”.$row['title'].”</strong>”;

//$row['title']=”<b>”.$row['title'].”</b>”;

$row['textlink']=”<ahref='”.$row['filename'].”'>”.$row['title'].”</a>”;

$row['plusurl']=$row['phpurl']=$GLOBALS['cfg_phpurl'];

$row['memberurl']=$GLOBALS['cfg_memberurl'];

$row['templeturl']=$GLOBALS['cfg_templeturl'];

if(is_array($dtp2->CTags))

{

foreach($dtp2->CTagsas$k=>$ctag)

{

if($ctag->GetName()=='array')

{

//传递整个数组,在runphp模式中有特殊作用

$dtp2->Assign($k,$row);

}else{

if(isset($row[$ctag->GetName()]))$dtp2->Assign($k,$row[$ctag->GetName()]);

else$dtp2->Assign($k,'');

}

}

$GLOBALS['autoindex']++;

}

$artlist.=$dtp2->GetResult().”

“;

}//ifhasRow

else{

$artlist.='';

}

}//LoopCol

}//loopline

$dsql->FreeResult(“al”);

}else

{

die(“RequestError!”);

}

AjaxHead();

echo$artlist;

exit();

© 版权声明
THE END
喜欢就支持一下吧
点赞6 分享