zoukankan      html  css  js  c++  java
  • zen cart 模板类 template_fun class

    第一次看到zen cart 的template类的代码,发现只有两个有用的函数,简单的超过我的想象,以前读过Smarty,phpBB,和Discuz的template 类,少说也有几百行,但是研究一通后,确实就是这样地。

    第一个有用的函数get_template_part

    在指定文件夹下面搜索,一定格式文件名的文件,返回这些文件名的数组。

    参数:$page_directory    指定的文件夹路径

            $template_part,    文件名开头部份

            $file_extension = '.php'   扩展名

    返回结果:

       文件名的数组,不包含文件夹,也不含路径的文件名

      function get_template_part($page_directory, $template_part, $file_extension = '.php') {
        $directory_array = array();
        if ($dir = @dir($page_directory)) {
          while ($file = $dir->read()) {
            if (!is_dir($page_directory . $file)) {
              if (substr($file, strrpos($file, '.')) == $file_extension && preg_match($template_part, $file)) {
                $directory_array[] = $file;
              }
            }
          }
    
          sort($directory_array);
          $dir->close();
        }
        return $directory_array;
      }

    第二个函数get_template_dir

    $template_code, $current_template, $current_page, $template_dir, $debug=false
  • 相关阅读:
    ceph简易安装
    ceph安装
    nova计算节点部署
    onva控制节点部署
    nova介绍
    image部署
    glance镜像介绍
    keystone部署
    keystone介绍
    rabbimtq消息队列部署
  • 原文地址:https://www.cnblogs.com/zqfleaf/p/1688887.html
Copyright © 2011-2022 走看看