在写hook_node_info()的时候,如果设置了min_word_count =10 ,可是已经输入了超过10汉字,应该可以了。但是还是错误,说字数太短。就觉得很奇怪,只好注销这个设定。这几天终于发现了这个min_word_count的设置意义。
大概看看下面的定义就会明白。
// Make sure the body has the minimum number of words.
// todo use a better word counting algorithm that will work in other languages
if (isset($node->body) && count(explode(' ', $node->body)) < $type->min_word_count) {
form_set_error('body', t('The body of your @type is too short. You need at least %words words.', array('%words' => $type->min_word_count, '@type' => $type->name)));
}
count(explode(' ', $node->body)) ,它是按照空格来算的,一个空格算一个词语,对英文来说就是min_word_count这么多个单词,而不是字节数。但是如果中文,大概就是十句话了。
"the minimum number of words." 最小的单词数量,而非字节。
评论
看不懂。不过每次来,都点了你二下google广告
看不懂。不过每次来,都点了你二下google广告
发表新评论