导航

随笔分类 -  开源项目 - Drupal

摘要:Drupal允许为管理后台设置独立的theme,保存在系统变量variable_get('admin_theme')。Drupal使用全局变量$theme来保存当前请求对应的主题。Drupal在启动时初始化$theme变量:function _drupal_bootstrap_full() { .... 阅读全文

posted @ 2014-05-23 11:57 eastson 阅读(441) 评论(0) 推荐(0) 编辑

摘要:Drupal的默认主题bartik会在页面顶部显示系统信息,例如警告、状态等。这个过程是如何实现的?首先,在bartik目录下找到page.tpl.php,这是bartik主题的页面显示模板。其中有一段是处理$messages的: 这里的$messages变量从哪里来的呢?在incl... 阅读全文

posted @ 2014-05-22 17:15 eastson 阅读(600) 评论(0) 推荐(0) 编辑

摘要:按登录非登录判断:uid){/*如果是当前浏览者为登录用户则显示下面的内容*/print;}else{/*如果是当前浏览者为非登录用户则显示下面的内容*/print;}?>按用户uid判断,这个很适合把一些特定区块只显示给管理员:uid==10){/*如果是当前浏览者登录且uid等于10则显示下面的... 阅读全文

posted @ 2014-05-19 08:48 eastson 阅读(293) 评论(0) 推荐(0) 编辑

摘要:问:如何校验和提交表单?答:Drupal允许定义默认的表单校验处理函数和提交处理函数。function practice_demo_form($form, &$form_state) { ... ... return $form;}function practice_demo_form_vali... 阅读全文

posted @ 2014-05-15 09:57 eastson 阅读(1340) 评论(0) 推荐(0) 编辑

摘要:原文地址:http://www.terrysco.com/node/drupal-as-mobile-backend.html用Drupal很容易实现一个API,让手机平台或者其他系统使用json的格式进行通信。 'login', 'register' => 'register', ... 阅读全文

posted @ 2014-05-07 10:40 eastson 阅读(350) 评论(0) 推荐(0) 编辑

摘要:Drupal使用_theme_build_registry()和_theme_process_registry()两个函数构建theme registry。theme registry是theme hook的集合组数。这里以practice模块定义两个theme hook为例,说明一下theme r... 阅读全文

posted @ 2014-05-05 15:30 eastson 阅读(312) 评论(0) 推荐(0) 编辑

摘要:drupal_render()只是对theme()的调用做了包装,真正做任务的还是theme()。function theme($hook, $variables = array()) { ... ...}theme()的开头检查了module_load_all()是否有执行。theme()只能在... 阅读全文

posted @ 2014-04-30 11:59 eastson 阅读(540) 评论(0) 推荐(0) 编辑

摘要:drupal_render()函数接收一个结构化的数组作为参数,然后调用theme()输出HTML。function drupal_render(&$elements) { ... ...}$elements['#printed']控制是否已经执行过,避免重复执行。在drupal_render()... 阅读全文

posted @ 2014-04-30 08:26 eastson 阅读(675) 评论(0) 推荐(0) 编辑

摘要:Drupal 7 driver for Microsoft SQL Server database engines. It supports both SQL Server (version 2008 and later), and SQL Azure, part of Microsoft Azur... 阅读全文

posted @ 2014-04-22 13:47 eastson 阅读(152) 评论(0) 推荐(0) 编辑

摘要:因个人需要需要重新安装Drupal。如何操纵呢?Drupal是在_drupal_bootstrap_database()函数里面检查是否已经安装过的。检查的依据是有没有$GLOBALS['databases']设置,或者是有没有设置常量MAINTENANCE_MODE=install。functio... 阅读全文

posted @ 2014-04-22 12:02 eastson 阅读(1106) 评论(0) 推荐(0) 编辑

摘要:Drupal在本阶段为用户设置缓存头信息。Drupal不为验证用户缓存页面,每次请求时都是从新读取的。function _drupal_bootstrap_page_header() { bootstrap_invoke_all('boot'); // 调用boot钩子, 只是启动模块 if (!drupal_is_cli()) { ob_start(); drupal_page_header(); }}function drupal_page_header() { $headers_sent = &drupal_static(__FUNCTION__, FALSE); 阅读全文

posted @ 2013-10-21 11:51 eastson 阅读(323) 评论(0) 推荐(0) 编辑

摘要:Drupal的很多功能都是可以定制的。以导航菜单为例,blog模块需要在菜单上添加一些功能,comment模块需要在菜单上添加一些功能,我们开发的自定义模块也需要在菜单上添加一些功能。Drupal开发者为了达到这样的扩展目的,设计了钩子系统,导航菜单就是其中一个名为menu的钩子。有了钩子系统,开发人员就可以在blog模块定义一个钩子函数从而实现menu钩子。Drupal要求钩子函数的命名必须要求以模块名开始,以钩子名为后缀。function block_menu() { $items['admin/structure/block/manage/%/%'] = array( & 阅读全文

posted @ 2013-10-17 17:21 eastson 阅读(381) 评论(0) 推荐(0) 编辑

摘要:Drupal的系统变量是指保存在后台数据库variable表中的一些参数设置,透过variable_get()和variable_set()存取:先看一看_drupal_bootstrap_variables()的代码:function _drupal_bootstrap_variables() { global $conf; // Initialize the lock system. require_once DRUPAL_ROOT . '/' . variable_get('lock_inc', 'includes/lock.inc'); 阅读全文

posted @ 2013-10-17 10:34 eastson 阅读(403) 评论(0) 推荐(0) 编辑

摘要:什么是模块载入?首先说载入,这里的载入是指require_once。模块载入就是指require_once模块目录中的某个PHP文件。每个Drupal模块都应该有自己的主文件。模块主文件以模块名开始,以.module为后缀。例如blog模块,其主文件就是blog.module。drupal_load()函数用来完成载入模块主文件:function drupal_load($type, $name) { static $files = array(); if (isset($files[$type][$name])) { return TRUE; } $filename = dru... 阅读全文

posted @ 2013-10-17 10:10 eastson 阅读(510) 评论(0) 推荐(0) 编辑

摘要:system_list()函数的目的是根据传入的资源类型,返回一个数组列表:function system_list($type) { ... ... }参数$type支持下面三种类型:bootstrap:返回启动模块列表module_enabled :返回模块列表theme:返回主题列表三种类型里面bootstrap处理方式有点不同,module_enabled和theme是相同的。先看看bootstrap是如此处理的。这里的bootstrap指的是系统表system里面标识为bootstrap的模块,是系统的启动模块,在Drupal启动过程中需要先被载入。首先检查是否有缓存:if ($ca 阅读全文

posted @ 2013-10-16 14:52 eastson 阅读(410) 评论(0) 推荐(0) 编辑

摘要:Drupal中,主题是可以继承的,或者说是扩展。例如,要创建一个新的名为custom的主题,该主题与名为default的主题只有某些细小的差别。这个时候,不需要复制一份default到custom,可以在custom声明该主题继承自default就可以了。主题的继承关系在info文件中说明。首先,default主题的info文件不需要修改:name = Default Themecustom主题的info文件需要特别地声明base theme属性:name = Custom Themebase theme = defaultDrupal内部是如何解析这种继承关系的呢?解析的过程发生在syste 阅读全文

posted @ 2013-10-16 14:39 eastson 阅读(288) 评论(0) 推荐(0) 编辑

摘要:Drupal能够识别哪些资源类型?profile,不知道怎么翻译,应该是指安装类型,固定地存放于profiles目录下。module,模块,可以存在于多个目录下:modules、profiles/{profile}/modules、sites/all/modules、sites/{$site}/modules。theme,主题,可以存在于多个目录下:themes、profiles/{profile}/themes、sites/all/themes、sites/{$site}/themes。theme_engine,主题引擎,可以存在于多个目录下:themes/engines、profiles/ 阅读全文

posted @ 2013-10-14 17:10 eastson 阅读(356) 评论(0) 推荐(0) 编辑

摘要:Drupal在数据库启动阶段仅仅是简单地包含了database.inc文件,然后再注册类加载器:function _drupal_bootstrap_database() { // Initialize the database system. Note that the connection // won't be initialized until it is actually requested. require_once DRUPAL_ROOT . '/includes/database/database.inc'; // Register autoload f 阅读全文

posted @ 2013-10-11 16:02 eastson 阅读(245) 评论(0) 推荐(0) 编辑

摘要:Drupal有时会显示白屏,或者500内部错误,这多半是由于PHP脚本什么地方有问题造成的。这个时候,可以先看看php.log里面有没有提示:[10-Oct-2013 15:55:26 Asia/Shanghai] PHP Fatal error: Call to undefined function xxxxxx() in C:\Program Files\Zend\Apache2\htdocs\drupal\index.php on line 24也可以将display_errors选项开启,使php将所有的信息都显示出来:error_reporting(E_ALL);ini_set(&# 阅读全文

posted @ 2013-10-10 16:03 eastson 阅读(434) 评论(0) 推荐(0) 编辑

摘要:Drupal在配置阶段的最开始就设置了自己的错误处理器和异常处理器:function _drupal_bootstrap_configuration() { set_error_handler('_drupal_error_handler'); set_exception_handler('_drupal_exception_handler'); // ... ...}先来看看错误处理器_drupal_error_handler()是如何做的?function _drupal_error_handler($error_level, $message, $file 阅读全文

posted @ 2013-10-10 11:48 eastson 阅读(1279) 评论(0) 推荐(0) 编辑