Home > CMS Tutorial > DEDECMS > body text

How to sort the list of DedeCMS DreamWeaver background templates alphabetically

藏色散人
Release: 2019-12-02 09:21:36
Original
2301 people have browsed it

How to sort the list of DedeCMS DreamWeaver background templates alphabetically

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.&#39;/&#39;.$filename);
$filetime = MyDate("Y-m-d H:i",$filetime);
$fileinfo = (isset($fileinfos[$filename]) ? $fileinfos[$filename] : &#39;未知模板&#39;);
?>
Copy after login

replaced by

<?php
   $files = scandir($templetdird);
   foreach ($files as $filename)
   {
      if(!preg_match("#.htm#", $filename)) continue;
      $filetime = filemtime($templetdird.&#39;/&#39;.$filename);
      $filetime = MyDate("Y-m-d H:i",$filetime);
      $fileinfo = (isset($fileinfos[$filename]) ? $fileinfos[$filename] : &#39;未知模板&#39;);
   ?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!