Hacks:“在词典和国家字符中按字母顺序浏览”
发布者:Zirafka于2010/1/8 15:20:00 阅读次数:8271如果你想要在模块“词典”中使“按字母顺序浏览”块显示国家字符,你可能会遇到问题。解决方案很简单
在文件INCLUDE/FUNCTION.PHP中搜索
函数 lx_alphaArray ()
{
global $xoopsUser, $xoopsDB, $xoopsModule;
$alpha = array();
for ($a = 65; $a < (65+26); $a++ )
{
$letterlinks = array();
$initial = chr($a);
$sql = $xoopsDB -> query ( "SELECT * FROM " . $xoopsDB -> prefix ( "lxentries") . " WHERE init = '$initial' " );
$howmany = $xoopsDB -> getRowsNum( $sql );
$letterlinks['total'] = $howmany;
$letterlinks['id'] = chr($a);
$letterlinks['linktext'] = chr($a);
$alpha['initial'][] = $letterlinks;
}
return $alpha;
}
替换操作
function lx_alphaArray (){
global $xoopsUser, $xoopsDB, $xoopsModule;
$pismenka = array("A","B","C","D","E","F","G","H","CH","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
$alpha = array();
for ($a = 0; $a < count($pismenka); $a++ )
{
$letterlinks = array();
$initial = $pismenka[$a];
$sql = $xoopsDB -> query ( "SELECT * FROM " . $xoopsDB -> prefix ( "lxentries") . " WHERE init = '$initial' " );
$howmany = $xoopsDB -> getRowsNum( $sql );
$letterlinks['total'] = $howmany;
$letterlinks['id'] = $pismenka[$a];
$letterlinks['linktext'] = $pismenka[$a];
$alpha['initial'][] = $letterlinks;
}
return $alpha;
}
数组 $pismenka[] 包含该模块使用的字符列表,简单使用您自己的国家字符即可。
此漏洞已在 Xoops 2.4.2 和 2.4.2(UTF-8)中进行过测试。
如此而已,祝您在使用 Xoops 时愉快