<?php
	$switcher = _ceo('switcher');
	if(_ceo('index_switcher_new_enable')){
        $switcher_zxfb=array(
            'enable5col'=>1,
            'num'=>10,
            'title'=>_ceo('index_switcher_new'),
            'id'=>(array) _ceo('index_switcher_new_cat_id'),
        );
        array_unshift($switcher, $switcher_zxfb);
    }

	if(!$switcher){
?>
<div class="ceo-container" >
	<div class="ceo-alert-primary" ceo-alert>
		<a class="ceo-alert-close" ceo-close></a>
		<p class="ceo-text-small"><i class="iconfont icon-warning-fill ceo-margin-small-right"></i>请前往后台<i class="iconfont icon-angle-right"></i>主题设置<i class="iconfont icon-angle-right"></i>首页设置<i class="iconfont icon-angle-right"></i>分类切换，设置该模块内容！</p>
	</div>
</div>
<?php }else {  ?>
<section class="switcher">
	<div class="ceo-container ceo-margin-medium-top ceo-margin-medium-bottom">
		<ul class="ceo-cat-switcher cat-switcher ceo-padding-remove" ceo-switcher>
		    <?php if(_ceo('switcher_title') ): ?>
		    <h5><?php echo _ceo('switcher_bt'); ?></h5>
		    <em></em>
		    <?php endif; ?>
			<?php
			   if ($switcher) {
				   foreach ( $switcher as $key => $value) {
			?>
			<li class="section-title ceo-display-inline-block ceo-flex ceo-flex-middle ceo-cat-switcher-z">
				<h3 class="ceo-flex-1 ceo-margin-remove ceo-position-relative"><?php
					   if(!$value['title']){
						   echo get_cat_name( $value['id'] );
					   }else {
						   echo $value['title'];
					   }
					?>
				</h3>
			</li>
			<?php } } ?>
		</ul>
		<div class="ceo-switcher ceo-padding-remove ceo-switcher-top">
			<?php
			   if ($switcher) {
				   foreach ( $switcher as $key => $value) {
                       $ceo_width_4='ceo-width-1-4';
                       if(!empty($value['enable5col'])){
                           $ceo_width_4='ceo-width-1-5';
            } ?>
			<div class="card ceo-animation-slide-left-small">
				<div class="ceo-grid-medium" ceo-grid>
					<?php
                   if(is_array($value['id'])){
                       query_posts(['category__in' => $value['id'], 'showposts' => $value['num']]);
                   }else{
                       query_posts('cat='.$value['id'] .'&showposts='.$value['num'] );
                   }

                    ?>
					<?php while (have_posts()) : the_post(); ?>
					<div class="ceo-width-1-1@s ceo-width-1-2 ceo-width-1-4@m ceo-width-1-4@l <?php echo $ceo_width_4; ?>@xl">
						<?php get_template_part( 'template-parts/home/loop', 'card' );?>
					</div>
					<?php endwhile; wp_reset_query(); ?>
				</div>
				<div class="section-more ceo-text-center ceo-margin-top-30 ceo-light">
					<a href="<?php echo get_category_link( $value['id'] ); ?>" target="_blank" class="btn change-color ceo-display-inline-block">查看更多<i class="iconfont icon-arrow-right"></i></a>
				</div>
			</div>
			<?php } } ?>
		</div>
	</div>
</section>
<?php } ?>
