diff --git a/plugins/Html.php b/plugins/Html.php index 495bf0f..a589b83 100644 --- a/plugins/Html.php +++ b/plugins/Html.php @@ -142,6 +142,21 @@ eof; 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 public static function getPaginationLink($url, $page, $pageSize = 24) { $arr = explode('?', $url); diff --git a/themes/beauty/views/site/index.php b/themes/beauty/views/site/index.php index 53b72e0..b9b39d8 100644 --- a/themes/beauty/views/site/index.php +++ b/themes/beauty/views/site/index.php @@ -195,7 +195,7 @@ eof; } if (!empty($category['files'])) { //一级目录支持 - $total = count($category['files']); //翻页支持 + $total = Html::getDataTotal($category['files'], $imgExts); //翻页支持 $pageStartIndex = ($viewData['page']-1) * $viewData['pageSize']; $index = 0; foreach ($category['files'] as $file) {