今天分享DedeCMS添加欄目的一個小技巧,添加欄目以簡拼作目錄名,以拼音首字母作文件夾名稱,默認情況情況下,DedeCMS添加欄目時是以全拼作為文件夾名稱,后臺也沒有提公簡拼的選項,但是我們可以通過修改源碼的方式實現。
因為DedeCMS在獲取欄目目錄名的時候,是利用的string助手的一個GetPinyin方法,具體這個方法可以見:http://www.heliweb.net/PHPDOC/DedeCMS-Helpers/_include---helpers---string.helper.php.html#functionGetPinyin, 通過說明我可以知道,在調用的時候,把第二個參數設置為1就能獲取到簡拼。
下面是具體方法:打開/dede/catalog_add.php 搜索GetPinyin 會搜索到4個,分別在85,108,134,187行,把這4個地方的4個方法的第二個參數設置成true或者1,完工,修改之后的四處分別如下:
$toptypedir = GetPinyin(stripslashes($toptypename),true);
$typedir = $toptypedir.'/'.GetPinyin(stripslashes($v),true);
$typedir = GetPinyin(stripslashes($typename),true);
$typedir = GetPinyin(stripslashes($typename),true);