php自动获取目录下的模板的代码
作者:bea
目录下必须有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 =='.'
目录下必须有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;
}
有用 | 无用
代码如下:
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;
}
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- php visitFile()遍历指定文件夹函数
- php excel类 phpExcel使用方法介绍
- php中使用ExcelFileParser处理excel获得数据(可作批量导入到数据库使用)
- 使用VisualStudio开发php的图文设置方法
- 利用Memcached在php下实现session机制 替换PHP的原生session支持
- ThinkPHP中实例Model方法的区别说明
- PHP 数组基础知识小结
- 一个简单php扩展介绍与开发教程
- php checkbox 取值详细说明
- PHP 截取字符串专题集合
- php 过滤器实现代码
- PHP对字符串的递增运算分析
- PHP原理之异常机制深入分析
- php include加载文件两种方式效率比较
- 将一维或多维的数组连接成一个字符串的php代码
- php简单提示框alert封装函数
- php递归实现无限分类生成下拉列表的函数
- php用数组返回无限分类的列表数据的代码
- php自定义函数之递归删除文件及目录