php自動獲取目錄下的模板的代碼
更新時間:2010年08月08日 17:14:43 作者:
php自定義函數(shù)之自動獲取目錄下的模板的實現(xiàn)代碼,一般制作模板分離的管理系統(tǒng)需要用得到。
目錄下必須有default.gif(此圖為模板縮略圖)的才為合法的模板
function get_template ()
{
$template = array ();
$dir = CMS_ROOT.'/tpl/';
$n = 0;
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ($file =='.' or $file == '..' or $file == '.svn')
{
continue;
}
if (is_dir ($dir.$file))
{
if (file_exists ($dir.$file.'/default.gif'))
{
$template[$n]['dir'] = $file;
$template[$n]['pic'] ='/tpl/'.$file.'/default.gif';
}
}
$n++;
}
closedir($dh);
}
}
return $template;
}
復(fù)制代碼 代碼如下:
function get_template ()
{
$template = array ();
$dir = CMS_ROOT.'/tpl/';
$n = 0;
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ($file =='.' or $file == '..' or $file == '.svn')
{
continue;
}
if (is_dir ($dir.$file))
{
if (file_exists ($dir.$file.'/default.gif'))
{
$template[$n]['dir'] = $file;
$template[$n]['pic'] ='/tpl/'.$file.'/default.gif';
}
}
$n++;
}
closedir($dh);
}
}
return $template;
}
您可能感興趣的文章:
- 讓你的博文自動帶上縮址的實現(xiàn)代碼,方便發(fā)到微博客上
- 用ajax自動加載blogjava和博客園的rss
- Linux下SVN服務(wù)器自動更新文件到Web目錄的方法
- rsync備份時自動創(chuàng)建目錄的方法
- 使用visual studio自動創(chuàng)建IIS虛擬目錄
- Windows下實現(xiàn)MySQL自動備份的批處理(復(fù)制目錄或mysqldump備份)
- 使用FTP下載目錄,即FTP命令批量自動下載的bat文件
- 使用ADSI、ASP和一對魔術(shù)戲法自動地創(chuàng)立一個虛擬目錄的方法
- 一個可以自動創(chuàng)建多級目錄的函數(shù)
- 詳解自動生成博客目錄案例
相關(guān)文章
PHP?redis?Sorted?Set實現(xiàn)字符串去重代碼示例
Redis中的Sorted?Set數(shù)據(jù)結(jié)構(gòu)可以用來存儲有序的唯一值,它們可以被用來構(gòu)建有序的集合或者有權(quán)重的數(shù)據(jù)結(jié)構(gòu),下面這篇文章主要給大家介紹了關(guān)于PHP?redis?Sorted?Set實現(xiàn)字符串去重的相關(guān)資料,需要的朋友可以參考下2023-05-05
PHP中break及continue兩個流程控制指令區(qū)別分析
php中常用的for與foreach循環(huán)中,經(jīng)常遇到條件判斷或中止循環(huán)的情況。而處理方式主要用到break及continue兩個流程控制指令,現(xiàn)在說明主要區(qū)別2011-04-04
深入解析yii權(quán)限分級式訪問控制的實現(xiàn)(非RBAC法)
本篇文章是對yii權(quán)限分級式訪問控制的實現(xiàn)方法進行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06

