Normal
0
7.8 磅
0
2
false
false
false
EN-US
ZH-CN
X-NONE
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.5pt;
mso-bidi-font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;
mso-font-kerning:1.0pt;}
症状:
进入版面的主题列表后,默认按照回帖时间倒序排列,页面底部选择其他排序方式后(发表时间、浏览次数等),再进入其他版面或其他操作后选择的排序方式失效。
测试分析:
排序方式的参数以GET的方式跟在链接后面,如forumdisplay.php?fid=8&orderby=dateline&ascdesc=desc
如此来传递参数给下一页,但切换到其他版面时(或很多其他操作时)没有传递该参数,导致用户选择失效。
由于牵涉到的页面和链接众多,一一修改链接地址和函数会及其繁琐,故考虑将用户的选择存入cookie中,每次读取页面时都从cookie中取得该参数的替代方案。
解决:
在forumdisplay.php文件中,找到如下两行:
isset($orderby) && in_array($orderby, array('lastpost',
'dateline', 'replies', 'views')) ? $forumdisplayadd .=
"&orderby=$orderby" : $orderby =
$_DCACHE['forums'][$fid]['orderby'] ? $_DCACHE['forums'][$fid]['orderby'] :
'lastpost';
isset($ascdesc) && in_array($ascdesc, array('ASC', 'DESC')) ?
$forumdisplayadd .= "&ascdesc=$ascdesc" : $ascdesc =
$_DCACHE['forums'][$fid]['ascdesc'] ? $_DCACHE['forums'][$fid]['ascdesc'] :
'DESC';
注释掉这两行,并且改为:
//如果用户选择了排序方式
if (isset($orderby) && in_array($orderby,
array('lastpost', 'dateline', 'replies', 'views'))) {
//(保留以防出错)
$forumdisplayadd
.= "&orderby=$orderby";
//将排序方式写入cookie中
dsetcookie('viewforumsorderby',
$orderby, 2592000);
}
Else
//如cookie中有排序方式则按照该排序方式,否则按照该版面的默认设定的排序方式,如也不存在则按照默认排序(回帖时间)
$orderby = $_DCOOKIE['viewforumsorderby']
? $_DCOOKIE['viewforumsorderby'] : ($_DCACHE['forums'][$fid]['orderby']
? $_DCACHE['forums'][$fid]['orderby'] : 'lastpost');
//升序/降序类似
if (isset($ascdesc) && in_array($ascdesc,
array('ASC', 'DESC')))
{
$forumdisplayadd
.= "&ascdesc=$ascdesc";
dsetcookie('viewforumsascdesc',
$ascdesc, 2592000);
}
else
$ascdesc = $_DCOOKIE['viewforumsascdesc']
? $_DCOOKIE['viewforumsascdesc'] : ($_DCACHE['forums'][$fid]['ascdesc']
? $_DCACHE['forums'][$fid]['ascdesc'] : 'DESC');
改完测试发现所有主题列表页面均能按照用户选择正常显示。
没有评论:
发表评论