發(fā)表日期:2018-08 文章編輯:小燈 瀏覽次數(shù):2903
我們知道織夢dedecms系統(tǒng)的后臺文件, 默認(rèn)的排序很亂, 不是按名稱, 也不是按時間, 如果目錄內(nèi)容很多的話, 很難找到自己想要的文件,實(shí)在是太不方便了, 就像下圖的排列方式那樣,找不到規(guī)律。
于是想讓這些文件列表按名字排序, 看了一下后臺的文件, 原來是因?yàn)閜hp的函數(shù)dir引起的, 以“默認(rèn)模板管理”在文件列表為例, 在后臺的找到模板文件: /你的后臺目錄/templets/templets_default.htm (dede為你的后臺目錄), 打開這個文件找到:
<?php$dh = dir($templetdird);while($filename=$dh->read()){if(!preg_match("#\.htm#", $filename)) continue;$filetime = filemtime($templetdird.'/'.$filename);$filetime = MyDate("Y-m-d H:i",$filetime);$fileinfo = (isset($fileinfos[$filename]) ? $fileinfos[$filename] : '未知模板');?> |
替換為
<?php $files = scandir($templetdird); foreach ($files as $filename) { if(!preg_match("#\.htm#", $filename)) continue; $filetime = filemtime($templetdird.'/'.$filename);$filetime = MyDate("Y-m-d H:i",$filetime);$fileinfo = (isset($fileinfos[$filename]) ? $fileinfos[$filename] : '未知模板'); ?> |
可以看得出來使用了PHP的dir函數(shù)導(dǎo)致的, dir()讀取的文件是無序的, 現(xiàn)在我們要想辦法讓他按名字排序, 這里可以改另一個讀取目錄文件的函數(shù)scandir(); 這個函數(shù)的文件會按文件名稱排序。
日期:2018-09 瀏覽次數(shù):4420
日期:2018-09 瀏覽次數(shù):3061
日期:2018-09 瀏覽次數(shù):3896
日期:2018-09 瀏覽次數(shù):3825
日期:2018-09 瀏覽次數(shù):3389
日期:2018-09 瀏覽次數(shù):3779
日期:2018-09 瀏覽次數(shù):3227
日期:2018-09 瀏覽次數(shù):3491
日期:2018-09 瀏覽次數(shù):3237
日期:2018-09 瀏覽次數(shù):3268
日期:2018-09 瀏覽次數(shù):2998
日期:2018-09 瀏覽次數(shù):3552
日期:2018-09 瀏覽次數(shù):3528
日期:2018-09 瀏覽次數(shù):3099
日期:2018-09 瀏覽次數(shù):3023
日期:2018-09 瀏覽次數(shù):3794
日期:2018-08 瀏覽次數(shù):2992
日期:2018-08 瀏覽次數(shù):3154
日期:2018-08 瀏覽次數(shù):2971
日期:2018-08 瀏覽次數(shù):2975
日期:2018-08 瀏覽次數(shù):3018
日期:2018-08 瀏覽次數(shù):2783
日期:2018-08 瀏覽次數(shù):2902
日期:2018-08 瀏覽次數(shù):2844
日期:2018-08 瀏覽次數(shù):2864
日期:2018-08 瀏覽次數(shù):3029
日期:2018-08 瀏覽次數(shù):3088
日期:2018-08 瀏覽次數(shù):3411
日期:2018-08 瀏覽次數(shù):2934
日期:2018-08 瀏覽次數(shù):3247
Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.