Drupal 7 开发内部培训资料, 分头诗人

能不能显示标题繁体字为简体字?

赞成!
0
否决!

如果标题是繁体字,内文是简体字。

在建立node时,能不能显示标题繁体字为简体字?

1 个回答

赞成!
0
否决!

可以,写个简单的模块就能实现,你找一个php代码:简体转繁体的,套在模块里面。

1,php加载mbstring

extension=php_mbstring.dll

2,配置mbstring

[mbstring]  
; language for internal character representation.  
; http://php.net/mbstring.language  
 mbstring.language = Chinese  
  
; internal/script encoding.  
; Some encoding cannot work as internal encoding.  
; (e.g. SJIS, BIG5, ISO-2022-*)  
; http://php.net/mbstring.internal-encoding  
 mbstring.internal_encoding =UTF-8  
  
; http input encoding.  
; http://php.net/mbstring.http-input  
 mbstring.http_input = auto  
  
; http output encoding. mb_output_handler must be  
; registered as output buffer to function  
; http://php.net/mbstring.http-output  
mbstring.http_output = UTF-8  
  
; enable automatic encoding translation according to  
; mbstring.internal_encoding setting. Input chars are  
; converted to internal encoding by setting this to On.  
; Note: Do _not_ use automatic encoding translation for  
;       portable libs/applications.  
; http://php.net/mbstring.encoding-translation  
 mbstring.encoding_translation = On  

3,PHP代码

function fantigetjianti($str) {  
    $fantis = "";  
    include "fanti2jiantiData.php";   //加载繁体字数组  
    for ($i = 0; $i <= mb_strlen($str); $i++) {  
        $fanti = mb_substr($str, $i, 1);  
        $jianti = $fantiData[$fanti];  
        if (empty($jianti)) {  
            $jianti = $fanti;  
        }  
        $fantis .=$jianti;  
    }  
    return $fantis;  
}