How to sort the DedeCMS DreamWeaver backend template list alphabetically?
We know that the default sorting of the background files of the Dedecms system is very messy, not by name or by time. If there is a lot of directory content, it will be difficult to find the files you want. It is really It is too inconvenient, just like the arrangement in the picture below, there is no pattern.
So I wanted to sort these file lists by name. I looked at the files in the background. It turned out to be caused by the php function dir. Take the "Default Template Management" file list as an example and find the template in the background. File: /your backend directory/templets/templets_default.htm (dede is your backend directory), open this file and find:
<?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] : '未知模板'); ?>
replaced by
<?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] : '未知模板'); ?>
You can see that PHP is used Caused by the dir function, the files read by dir() are out of order. Now we have to find a way to sort them by name. Here we can change another function scandir() that reads directory files; the files of this function will be sorted by name. File name sorting.
The above is the detailed content of How to sort the list of DedeCMS DreamWeaver background templates alphabetically. For more information, please follow other related articles on the PHP Chinese website!