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