Skip to content

Commit

Permalink
✨ 优化首页幻灯片为空时顶部的空白边距 #471
Browse files Browse the repository at this point in the history
  • Loading branch information
Licoy committed Feb 27, 2025
1 parent c4def51 commit 3c71ff7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion inc/fun/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -1020,4 +1020,4 @@ function pk_load_template($_template_file, $require_once = true, $args = array()
{
status_header(200);
load_template($_template_file, $require_once, $args);
}
}
16 changes: 16 additions & 0 deletions inc/fun/opt.php
Original file line number Diff line number Diff line change
Expand Up @@ -642,3 +642,19 @@ function pk_post_expire_tips_open($content)
if (pk_is_checked('post_expire_tips_open')) {
add_filter('the_content', 'pk_post_expire_tips_open');
}


function pk_ava_home_banners()
{
$index_carousel_list = pk_get_option('index_carousel_list', []);
if (is_array($index_carousel_list) && count($index_carousel_list) > 0){
$ava = [];
foreach ($index_carousel_list as $item){
if (($item['hide'] ?? false) || empty($item['img'])) continue;
$ava[] = $item;
}
return $ava;
}else{
return false;
}
}
3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
<?php get_template_part('templates/box', 'global-top') ?>
<div class="row row-cols-1">
<div class="col-lg-<?php pk_hide_sidebar_out('12', '8') ?> col-md-12 <?php pk_open_box_animated('animated fadeInLeft') ?> ">
<?php if (isset($paged) && $paged <= 1): ?>
<?php if (isset($paged) && $paged <= 1): $home_banner_ava = pk_ava_home_banners(); if(is_array($home_banner_ava) && count($home_banner_ava)>0):?>
<div class="<?php pk_open_box_animated('animated fadeInLeft') ?>">
<?php get_template_part('templates/module', 'banners') ?>
</div>
<?php endif; ?>
<?php endif; ?>
<div class="<?php pk_open_box_animated('animated fadeInLeft') ?>
<?php echo pk_post_style_list() ? '' : 'pr-0 pl-0' ?>">
<div>
Expand Down
7 changes: 3 additions & 4 deletions templates/module-banners.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
use Puock\Theme\setting\options\OptionCarousel;

if (pk_is_checked('index_carousel')):
$index_carousel_list = pk_get_option('index_carousel_list', []);
if (is_array($index_carousel_list) && count($index_carousel_list) > 0):
global $home_banner_ava;
if (is_array($home_banner_ava) && count($home_banner_ava) > 0):
?>
<div id="index-banners" data-swiper="init" data-swiper-class="index-banner-swiper"
data-swiper-args='<?php echo OptionCarousel::getCarouselIndexArgs() ?>'
Expand All @@ -14,8 +14,7 @@ class="mb15">
<div class="swiper-wrapper">
<?php
$index_carousel_hide_title = pk_is_checked('index_carousel_hide_title');
foreach ($index_carousel_list as $item):
if (($item['hide'] ?? false) || empty($item['img'])) continue
foreach ($home_banner_ava as $item):
?>
<div class="swiper-slide swiper-lazy">
<a data-no-instant href="<?php echo $item['link'] ?? 'javascript:void(0);' ?>"
Expand Down

0 comments on commit 3c71ff7

Please sign in to comment.