‘$pubdate’,'$senddate’,'$arcatt’,'$adminID’,'0′,’$description’,'$keywords’,'$templet’,'$redirecturl’,‘$pytitle’);”;
通过系统函数GetPingyin获得文章标题的拼音首字母,并生成insert语句,保存标题拼音首字母到pytitle字段。
类似,修改article_eidt_action.php为:
//用拼音命名
if($upinyin==1) $pytitle = str_replace(“_”,”",GetPinyin($title,1));
//更新数据库的SQL语句
//———————————-
$inQuery = ”
update dede_archives set
typeid=’$typeid’,
typeid2=’$typeid2′,
sortrank=’$sortrank’,
redirecturl=’$redirecturl’,
iscommend=’$iscommend’,
ismake=’$ismake’,
arcrank=’$arcrank’,
money=’$money’,
title=’$title’,
color=’$color’,
writer=’$writer’,
source=’$source’,
litpic=’$litpic’,
pubdate=’$pubdate’,
description=’$description’,
keywords=’$keywords’,
templet=’$templet’,
shorttitle=’$shorttitle’,
arcatt=’$arcatt’,
pytitle=’$pytitle’
where ID=’$ID’; “;
第三步,修改首页模板,或者其它需要使用这个功能的模板。
<div>中文按声母排列:<a href=http://www.dede58.com/”/plus/search.php?keyword=a&searchtype=pytitle”>A</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=b&searchtype=pytitle”>B</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=c&searchtype=pytitle”>C</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=d&searchtype=pytitle”>D</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=e&searchtype=pytitle”>E</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=f&searchtype=pytitle”>F</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=g&searchtype=pytitle”>G</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=h&searchtype=pytitle”>H</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=j&searchtype=pytitle”>J</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=k&searchtype=pytitle”>K</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=l&searchtype=pytitle”>L</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=m&searchtype=pytitle”>M</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=n&searchtype=pytitle”>N</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=o&searchtype=pytitle”>O</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=p&searchtype=pytitle”>P</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=q&searchtype=pytitle”>Q</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=r&searchtype=pytitle”>R</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=s&searchtype=pytitle”>S</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=t&searchtype=pytitle”>T</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=w&searchtype=pytitle”>W</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=x&searchtype=pytitle”>X</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=y&searchtype=pytitle”>Y</a> – <a href=http://www.dede58.com/”/plus/search.php?keyword=z&searchtype=pytitle”>Z</a> <- 中文软件名按第一汉字声母排列</div>
其中关键部分为keyword=字母&searchtype=pytitle。
第四步,我们通过search.php实现搜索,dedecms不允许小于3个字符的搜索,因此我们要修改它。
修改/plus/search.php文件,修改的部分为红色:
//判断是否为声母搜索
if($searchtype<>”pytitle”){
if($keyword==”"||strlen($keyword)<3){
ShowMsg(“关键字不能小于3个字节!”,”-1″);
exit();
}
}
第五步,修改并实现搜索。
修改/include/inc_arcsearch_view.php,目标:
获得字母关键字,生成新的检索条件,获取搜索类型关键字($searchtype),调用不同的显示模板。
好的,我们继续修改,修改如下,红色部分为新增或者修改的部分。
修改function GetKeywordSql()函数,新增:
//声母搜索支持
if($this->SearchType==”pytitle”){
$kwsql .= ” And dede_archives.pytitle like ‘$this->Keywords%’ “;
}
建议放在foreach($ks as $k){…}下面