小说伪造详情页面 代码优化

This commit is contained in:
make
2025-07-29 22:39:17 +08:00
parent 89b32cdb9b
commit 926bdc3ef2
8 changed files with 107 additions and 138 deletions

View File

@@ -168,19 +168,18 @@
<p>相邻推荐:
{php}
$arrRandomForgeNovels = [];
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
$forgeNovels = $arrNovel['n_forge_novel'];
if (count($forgeNovels) > 10) {
$randomKeys = array_rand($forgeNovels, 10);
$arrRandomForgeNovels = array_intersect_key($forgeNovels, array_flip($randomKeys));
} else {
$arrRandomForgeNovels = $forgeNovels;
shuffle($arrRandomForgeNovels);
$arrRandomForgeNovels = [];
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
$forgeNovels = $arrNovel['n_forge_novel'];
$count = count($forgeNovels);
if ($count > 0) {
$randomKeys = array_rand($forgeNovels, min(10, $count));
foreach ((array) $randomKeys as $key) {
$arrRandomForgeNovels[] = $forgeNovels[$key];
}
$arrRandomForgeNovels = array_values($arrRandomForgeNovels);
}
{/php}
}
}
{/php}
{volist name='arrRandomForgeNovels' id='ForgeNovel' key="key"}
{if !empty($arrGrm[$key+20])}