functiondrupal_explode_tags($tags) { // This regexp allows the following types of user input: // this, "somecompany, llc", "and ""this"" w,o.rks", foo bar $regexp = '%(?:^|,\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^",]*))%x'; preg_match_all($regexp, $tags, $matches); $typed_tags = array_unique($matches[1]);
$tags = array(); foreach ($typed_tagsas$tag) { // If a user has escaped a term (to demonstrate that it is a group, // or includes a comma or quote character), we remove the escape // formatting so to save the term into the database as the user intends. $tag = trim(str_replace('""', '"', preg_replace('/^"(.*)"$/', '\1', $tag))); if ($tag != "") { $tags[] = $tag; } }
这个需要修改核心代码了,把英文的,改为汉语的,就可以了。D
这个需要修改核心代码了,把英文的,改为汉语的,就可以了。
Drupal默认是英文的逗号,改为中文的,不过不建议修改核心代码。
但我不知道修改哪里? 我在taxonomy.module
但我不知道修改哪里? 我在taxonomy.module 看了又看, 都还不知道怎么改。
Drupal explode
Drupal explode tags,修改里面的英文逗号就可以了.
以前也遇到过这个问题,不过Drupal没有提供更好的办法解决,只能修改核心代码并使用patch了.
function drupal_explode_tags($tags) {
// This regexp allows the following types of user input:
// this, "somecompany, llc", "and ""this"" w,o.rks", foo bar
$regexp = '%(?:^|,\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^",]*))%x';
preg_match_all($regexp, $tags, $matches);
$typed_tags = array_unique($matches[1]);
$tags = array();
foreach ($typed_tags as $tag) {
// If a user has escaped a term (to demonstrate that it is a group,
// or includes a comma or quote character), we remove the escape
// formatting so to save the term into the database as the user intends.
$tag = trim(str_replace('""', '"', preg_replace('/^"(.*)"$/', '\1', $tag)));
if ($tag != "") {
$tags[] = $tag;
}
}
return $tags;
}
?>