十/082
drupal中文文档中缺少部分翻译
这几天看那个drupal模块开发手册的时侯,发现网上流传的翻译中文文档少了一部份,一些朋友可能不连贯看不太明白,补充上。在Working with Nodes这章的开始部份少了对node_info这个hook的介绍,翻译补充如下:
Now you’re ready to add hooks to joke.module. The first hook you’ll want to implement is hook_node_info(). Drupal calls this hook when it’s discovering which node types are available. You’ll provide some metadata about your custom node.
现在你可以为joke.module添加钩子函数了。你首先要实现的就是hook_node_info()这个钩子,drupal会在查找哪个节点类型可用时调用这个钩子。你要为你自定义的节点类型提供一些元数据。
/**
* Implementation of hook_node_info().
*/
function joke_node_info() {
// We return an array since a module can define multiple node types.
// We’re only defining one node type, type ‘joke’.
return array(
‘joke’ => array(
‘name’ => t(‘Joke’), // Required.
‘module’ => ‘joke’, // Required.
‘description’ => t(‘Tell us your favorite joke!’), // Required.
‘has_title’ => TRUE,
‘title_label’ => t(‘Title’),
‘has_body’ => TRUE,
‘body_label’ => t(‘Joke’),
‘min_word_count’ => 2,
‘locked’ => TRUE
)
);
}
A single module can define multiple node types, so the return value should be an array. Here’s the breakdown of metadata values that may be provided in the node_info() hook:
单个模块可以定义多个节点类型,所以返回值可以是一个数组。下面对一些node_info()钩子中的元数据进行分析:
• name (required): The name of the node to display on the site. For example, if the value is ‘Joke’, Drupal will use this when titling the node submission form.
名称(必须指定):节点类型的名称,例如,如果name值为Joke,在节点提交表单中的标题就会使用这个值。
• module (required): The name of the prefix of the callback function Drupal will look for. We used ‘joke’, so Drupal will look for callback functions named joke_validate(), joke_insert(), joke_delete(), and so on.
模块(必须指定):指定Drupal要寻找的回调函数的前缀。我们这里使用joke,所以drupal会寻找命名为joke_validate(), joke_insert(), joke_delete()等等的回调函数。
• description: This is generally used to add a brief description about what this content type is used for. This text will be displayed as part of the list on the “Create content” page (http://example.com/?q=node/add).
描述:这个值用来为该类型的用途做一个简要描述。这个描述会在创建内容页面显示。
• has_title: Boolean value indicating whether or not this content type will use the title field. The default value is TRUE.
has_title:布尔值,控制该节点类型是否使用title这个字段。默认为TRUE(使用title)。
• title_label: The form field text label for the title field. This is only visible when has_title is TRUE. The default value is Title.
title_label:表单中title字段的文本标记,只有当has_title为TRUE时才可见。默认为Title
• has_body: Boolean value that indicates whether or not this content type will use the body textarea field. The default value is TRUE.
has_body: 布尔值,控制该节点类型是否使用body这个文本区域字段。默认为TRUE(使用body)。
• body_label: The form field text label for the body textarea field. This is only visible when has_body is TRUE. The default value is Body.
body_label:表单中body字段的文本标记,只有当has_body为TRUE时才可见。默认为Body
• min_word_count: The minimum number of words the body textarea field needs to pass validation. The default is 0. (We set it to 2 in our module to avoid one-word jokes.)
最少字数:body字段要达到该字数以上才能通过验证。默认为0
• locked: Boolean value indicating whether the internal name of this content type is locked from being changed by a site administrator. The default value for locked is TRUE, meaning the name is locked and therefore not editable.
锁定:布尔值,指定是否允许管理员修改这个内容类型的内部名称。默认不允许编辑。
注意: 在前面列表中提到的内部名称字段,是用来构造“创建内容(create content)”链接的URL的。例如,我们使用“joke”作为我们节点类型的内部名称(它是我们返回的数组的键),那么要创建一个新的笑话的话,用户要访问页面http://example.com/?q=node/add/joke。通常你不需要对此作出修改。内部名称存储在表node 和 node_revisions的“type”列中。
19:46 on 五月 9th, 2011
Give thanks to your for spreading the experience involving you life. Were at the similar place. We can determine the way it should be by sharing.
10:39 on 一月 26th, 2012
?????? ????? ?????? ???? ?????? ????? ????? ??? ????? ????? 6, ????? 3 ???? ????? ????? ??? ????, ?? ????? ???? ?????? ????, ????? ????.