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);
  • 相关阅读:
    flask的简单使用
    Android Studio 使用Lambda表达式
    安卓SDK更新 国内镜像站点记录
    REACT-NATIVE入门(环境搭建及HELLOWORLD)
    深入理解Android 读感(一)
    JNI初入手
    (转)c++ 中的using namespace std是什么意思,什么时候用
    (转)const char to LPCTSTR不能转化问题
    Git常用操作之add操作
    Git日志操作
  • 原文地址:https://www.cnblogs.com/qinqiu/p/4492565.html
Copyright © 2011-2022 走看看