You are here

我有个分类的问题

cybershan 的头像
Submitted by cybershan on 星期六, 2009-11-21 17:28

我安装了drupal6.14,  并起用了taxonomy建立分类(tag)。

发现用户只能有英文的逗号作为tag的分隔符, 这点符合中国人的习惯, 怎样改成中文的逗号或顿号??

谢谢。 

 

论坛:

g089h515r806 的头像

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;
}
?>