Browse Source

bug fix: wrong total of files

master
filesite 5 months ago
parent
commit
55a152c5f2
  1. 15
      plugins/Html.php
  2. 2
      themes/beauty/views/site/index.php

15
plugins/Html.php

@ -142,6 +142,21 @@ eof;
return "{$cdn}{$localImgUrl}"; return "{$cdn}{$localImgUrl}";
} }
//根据文件类型,获取数组中符合条件文件总数
public static function getDataTotal($files, $fileTypes) {
$total = 0;
foreach ($files as $file) {
if (empty($file['extension']) || !in_array($file['extension'], $fileTypes)) {
continue;
}
$total ++;
}
return $total;
}
//参数:page、limit //参数:page、limit
public static function getPaginationLink($url, $page, $pageSize = 24) { public static function getPaginationLink($url, $page, $pageSize = 24) {
$arr = explode('?', $url); $arr = explode('?', $url);

2
themes/beauty/views/site/index.php

@ -195,7 +195,7 @@ eof;
} }
if (!empty($category['files'])) { //一级目录支持 if (!empty($category['files'])) { //一级目录支持
$total = count($category['files']); //翻页支持 $total = Html::getDataTotal($category['files'], $imgExts); //翻页支持
$pageStartIndex = ($viewData['page']-1) * $viewData['pageSize']; $pageStartIndex = ($viewData['page']-1) * $viewData['pageSize'];
$index = 0; $index = 0;
foreach ($category['files'] as $file) { foreach ($category['files'] as $file) {

Loading…
Cancel
Save