Browse Source

link of year and month update

master
filesite 1 month ago
parent
commit
8d6d918ace
  1. 4
      themes/beauty/controller/CommandController.php
  2. 11
      themes/beauty/controller/ListController.php
  3. 14
      themes/beauty/views/list/bydate.php

4
themes/beauty/controller/CommandController.php

@ -388,7 +388,9 @@ eof; @@ -388,7 +388,9 @@ eof;
$filesByFirstChar = $this->getFilesByFirstCharcter($cacheData, $dirNum);
$cacheDir = 'index';
for ($i=1;$i<=$dirNum;$i++) {
Common::saveCacheToFile("{$cacheKey}_{$i}", $filesByFirstChar[$i-1], $cacheDir);
if (!empty($filesByFirstChar[$i-1])) {
Common::saveCacheToFile("{$cacheKey}_{$i}", $filesByFirstChar[$i-1], $cacheDir);
}
}
//保存文件总数,以及分批数量,以便前端根据id来索引数据

11
themes/beauty/controller/ListController.php

@ -495,6 +495,15 @@ Class ListController extends Controller { @@ -495,6 +495,15 @@ Class ListController extends Controller {
}
}
//只显示有数据的月份
$monthsByType = [];
foreach($cacheData as $month => $arr) {
if (!empty($arr)) {
array_push($monthsByType, $month);
}
}
sort($monthsByType);
//按月份筛选数据
if (!empty($para_month)) {
$newData = [];
@ -612,7 +621,7 @@ Class ListController extends Controller { @@ -612,7 +621,7 @@ Class ListController extends Controller {
'page', 'pageSize', 'showType',
'allFiles',
'cacheData',
'cacheData_keys',
'cacheData_keys', 'monthsByType',
'para_year', 'para_month'
);
return $this->render($viewName, $params, $pageTitle);

14
themes/beauty/views/list/bydate.php

@ -168,7 +168,11 @@ eof; @@ -168,7 +168,11 @@ eof;
echo '<ul class="nav nav-tabs ml-1 mb-1">';
foreach ($arrShowTypes as $key => $title) {
$showLink = Html::getLinkByParams(FSC::$app['requestUrl'], array('show' => $key, 'page' => 1));
$showLink = Html::getLinkByParams(FSC::$app['requestUrl'], array(
'show' => $key,
'page' => 1,
'month' => '',
));
$activedClass = $key == $viewData['showType'] ? 'active' : '';
echo <<<eof
<li role="presentation" class="{$activedClass}"><a href="{$showLink}">{$title}</a></li>
@ -191,8 +195,12 @@ eof; @@ -191,8 +195,12 @@ eof;
<li role="presentation" class="{$activedClass}"><a href="{$monthLink}">所有</a></li>
eof;
$months = $viewData['cacheData_keys'][$viewData['para_year']];
asort($months); //排序
$months = $viewData['monthsByType'];
if ($viewData['showType'] == 'all') {
$months = $viewData['cacheData_keys'][$viewData['para_year']];
sort($months); //排序
}
foreach ($months as $month) {
$intMonth = str_replace('m', '', $month);
$activedClass = $month == $viewData['para_month'] ? 'active' : '';

Loading…
Cancel
Save