You are here

Carson的29个drupal问题

g089h515r806 的头像
Submitted by g089h515r806 on 星期六, 2008-11-08 10:16

这周我会专门针对这些问题,作出回复,不准的地方希望大家一起纠正,完善。

1、module 开发
2、theming 开发
3、database 如何控制我新增加的表格采用不同的表前缀(以模块区分)
4、- drupal 中的hook menu项,有
   MENU_CALLBACK  -- 表示不在管理列表中显示,而是做为一个普通的应用程序
   MENU_NORMAL_ITEM -- 表示需要在后台设置菜单栏中显示

   _perm   存放相应的模块权限关键字

   _admin_settings  模块参数设置函数,函数最终通过system_settings_form($form); 绘制相应的form表单,系统会自动
将管理人员输入的参数保存至drupal的系统参数配制表,并通过variable_get(NODEVOTE_RESULT_DISPLAY_TEASER, 0)获取相
应的系统参数配置值,第一个参数代表关键字,第二个参数代表默认值。

5、drupal 调试时输出其对应的SQL语句

6、
Database abstraction layer
http://api.drupal.org/api/group/database/6

7、drupal 对模块也使用了相关的缓存系统,有没有相应的开发者插件,可以在修改相应的模块代码之后,立即更新相应的缓存,或使缓存无效,并立即测试新代码?

8、如何设置多个域名指向drupal,但是分别有不同的界面,且可以指向不同的应用。

9、%% Inserts a literal % sign (e.g., SELECT * FROM {users} WHERE name LIKE '%%%s%%')

10、The
status field in the node table is 0 for unpublished nodes and 1 for published nodes.

11、Getting a Limited Range of Results
$sql = "SELECT * FROM {node} n WHERE type = 'blog' AND status = 1 ORDER BY
n.created DESC";
$result = db_query_range(db_rewrite_sql($sql), 0, 10);

12、pager_query()  ????  分页使用

13、form_set_error  在form 中显示错误信息
form_set_error('decision', t('You must agree to the Legal Agreement
before registration can be completed.'));
在字段decision中显示错误信息You must agree to the Legal Agreement
before registration can be completed.

14、watchdog('user', t('User %user agreed to legal terms',
array('%user' => $user->name)));
写入日志

15、   $fields['legel_agreement']['decision'] = array(
    '#type' => 'radios',
    '#description' => t('这是法律声明的条款'),
    '#default_value' => 0,
    '#options' => array(t('I disagree'),t('I agree'))
   );
array(
'yes' => ''
)

产生的值为0,1,如何重新指定其值的内容。

16、 ($user->uid == $node->uid));  用此方式来验证当前的用户的否是文章的所有者

17、控制用户对节点数据的访问
。你可以创建一些其它的钩子函数并直接操纵 $node->teaser 的值来控制对它的访问,但是这有点麻烦。一个好的解决方案是使用我们将在后面简短讨论到的函数 hook_node_grants() 和 hook_db_rewrite_sql()。

18、我的JOKE安装模块为何不能够使用?

19、
if ($node->revision) {
joke_insert($node);
}
else {
db_query("UPDATE {joke} SET punchline = '%s' WHERE vid = %d",
$node->punchline, $node->vid);
}

20、
模板函数的复写,本例复写(theme_breadcrumb($breadcrumb):
function mytheme_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
$variables = array(
'breadcrumb' => implode(' * ', $breadcrumb)
);
return _phptemplate_callback('breadcrumb', $variables);
}
}
这个函数的关键点在于 _phptemplate_callback()。它的第一个参数是要查找的模板文件的名字,第二个参数是传递给模板文件的变量数组。你的模板文件需要多少变量,你就可以创建并传递多少。

21、delta:由于一个模块可以在钩子方法 hook_block() 中定义多个区块,那么 delta 存放了每个区块的键值。它们在钩子方法范围内是唯一的,但对于整个站点的所有区块则不一定唯一。通过后台接口创建的区块的 delta 字段,同时作为表 blocks 的 bid 字段的主键。delta 可以是整数,也可以是字符串?????

22、Take note of how we used drupal_get_destination() in the preceding code. This function
remembers the page you were on before you submitted a form, so after you update the comment
form to publish or delete a comment, you’ll be automatically redirected from whence you came.

23、如果一个theme启动,则一个theme所设置的所有区块,不会在新的THEME中显示,需要重新指定其区块的显示才可以。

24、我开发的表单应用,为什么不好用formexample?

25、form中使用下接列表选择框
$form['color_options'] = array(
'#type' => 'value',
'#value' => array(t('red'), t('green'), t('blue'))
);
$form['color']['favorite_color'] = array(
'#title' => t('Favorite Color'),
'#type' => 'select',
'#description' => t('Please select your favorite color.'),
'#options' => $form['color_options']['#value']
);

如何表示键、值格式的数据,即(红色=>red,绿色=>green)

26、hook_search()高级应用?

27、drupal 中的分类详细介绍?

28、drupal_add_js(drupal_get_path('module', 'plus1') .'/jquery.plus1.js');
drupal_add_css(drupal_get_path('module', 'plus1') .'/plus1.css');

29、XML-RPC不会生成相应的SOAP的文件吗?

论坛:

g089h515r806 的头像

1,模块开发这个可以参看pro drupal里面的内容,现在关于drupal6.x的资料还是比较少了。不过我看到不少热心的网友已经贴出了相应的教程。不过对于模块开发,最好的方式就是自己实践。