カテゴリをわかりやすく・・・Vol.1

カテゴリ名に日本語を使用できるようにということになると、higuti.comのここに、globalfunctions.phpを書き換える方法があった。
以下引用
512行目:isValidCategoryName関数全体を差し替え
function isValidCategoryName($name) { return eregi(‘^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$’, $name); }
を次のように変更します(ただし、これは内部文字コードがEUCの場合しか動きません)。
function isValidCategoryName($name) {
$ascii = ‘[?x00-?x7F]’; # 1バイト EUC-JP文字
$twoBytes = ‘(?:[?x8E?xA1-?xFE][?xA1-?xFE])’; # 2バイト EUC-JP文字
$threeBytes = ‘(?:?x8F[?xA1-?xFE][?xA1-?xFE])’; # 3バイト EUC-JP文字
$character = “(?:$ascii|$twoBytes|$threeBytes)”; # EUC-JP文字
return preg_match(“/^$character+$/”, $name);
}
引用終了
当該サイト
今回は、これではなく、higuchi.comのその後の記述にあるように、
カテゴリ名に日本語を使うのではなく、カテゴリ名はascii文字(英数字)のままで、Descriptionを表示するPluginを使う方法をとることにする。
まみおさんの記事参照
当該Plugin:NP_CatDesc.php
As far as I know, it’s not possible to print out the category description from a template. There’s a skinvar (<%category(desc)%>), but no template variable to do the trick. Why did I need that? Because category names are rather restricted: I can’t use Scandinavian characters in the category names. Descriptions have no such restrictions.
ようは、スキンの編集でDescriptionを表示したいところに、<%category(desc)%>と入れることで、Descriptionを表示できるの(標準機能)だが、ここでも日本語(2バイト文字)は扱えないので、
このNP_CatDesc.phpというPluginを入れて、テンプレート内に、<%CatDesc%> を書けばいいらしい。
と、書いたが、後日細かいところが判明。
詳しくは、カテゴリをわかりやすく・・・Vol.2を参照

コメント

タイトルとURLをコピーしました