zoukankan      html  css  js  c++  java
  • theme('item-list',array('items'=>array('aaa','bbb'))) 是如何运行的 ?

    $items['items'] = array(
        l('Configure', 'admin/config'),
        l('Structure', 'admin/structure'),
    );
    $theme =  theme('item_list', $items);
    

    首先会跳转到这个函数

    function theme( $hook, $variables )

    1,  判断是否所有的模块都加载了,

    if (!module_load_all(NULL) && !defined('MAINTENANCE_MODE')) {
        throw new Exception(t('theme() may not be called until all modules are loaded.'));
      }

    2,  获得所有的ThemeRegistry信息, 这个信息就是所有模块定义的hook_theme的数组, 并合并了很多默认的信息, 比如process function, function, render array, variables,etc

     $hooks = theme_get_registry(FALSE);

    3,  获得这次的ThemeHook所对应的ThemeRegistry信息

    $info = $hooks[$hook];

    4,  如果hook_theme定义了includes, 那就加载函数

    if (!empty($info['includes'])) {
        foreach ($info['includes'] as $include_file) {
          include_once DRUPAL_ROOT . '/' . $include_file;
        }
      }

     5,  吧$variable和ThemeRegistry对应这次hook的variable合并

      if (!empty($info['variables'])) {
        $variables += $info['variables'];
      }

    6, $info里面process preprocess function被调用

    $processor_function($variables, $hook_clone);

    7, 如果在process preprocess function里改变了$variable['theme_hook_suggestion']的话, 会重新加载$hook

     $info = $hooks[$suggestion];

    8, $info里面的function会被调用来处理$variable

     $output = $info['function']($variables);
  • 相关阅读:
    推荐一波好的代码托管
    二十一、如何导入svg图片
    二十、滑动开关css
    十九、CSS如何引入字体
    十八、移动端rem布局
    十五、css3 Filter--滤镜
    十四、css动画基础知识
    十三、初始化标签默认样式
    十二、移动端头部声明
    十一、使用a标签打电话、发短信、发邮件
  • 原文地址:https://www.cnblogs.com/qinqiu/p/4492565.html
Copyright © 2011-2022 走看看