<?php
/**
 * The Template Name: Home Page
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site will use a
 * different template.
 *
 * @package Solar Panels
 */

get_header(); ?>

<div id="content">
  <?php
    $solar_services_hidcatslide = get_theme_mod('solar_services_hide_categorysec', true);
    $solar_services_slidersection = get_theme_mod('solar_services_slidersection');
    if ($solar_services_hidcatslide && $solar_services_slidersection) { ?>
    <section id="catsliderarea">
        <div class="catwrapslider">  
          <div class="owl-carousel">
            <?php if( get_theme_mod('solar_services_slidersection',false) ) { ?>
            <?php $solar_services_queryvar = new WP_Query('cat='.esc_attr(get_theme_mod('solar_services_slidersection',false)));
              while( $solar_services_queryvar->have_posts() ) : $solar_services_queryvar->the_post(); ?>
                <div class="slidesection"> 
                  <?php if(has_post_thumbnail()){
                    the_post_thumbnail('full');
                    } else{?>
                    <img src="<?php echo esc_url(get_theme_file_uri()); ?>/images/slider.png" alt="<?php echo esc_attr( 'slider', 'solar-panels'); ?>"/>
                  <?php } ?>
                  <div class="cover">
                    <div class="slider-box">
                      <h1 class="big-title mb-3"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
                      <div class="slider-btn mt-md-4">
                        <?php if (get_theme_mod('solar_services_button_text', 'Our Service') != "" && get_theme_mod('solar_services_button_link_slider') != '') { ?>
                            <a class="mb-2 btn1" href="<?php echo esc_url(get_theme_mod('solar_services_button_link_slider', '')); ?>"><?php echo esc_html(get_theme_mod('solar_services_button_text', __('Our Service', 'solar-panels'))); ?><i class="far fa-arrow-alt-circle-right ms-2"></i><span class="screen-reader-text"><?php echo esc_html(get_theme_mod('solar_services_button_text', __('Our Service', 'solar-panels'))); ?></span></a>
                        <?php } ?>
                        <?php 
                          $solar_services_button_text2 = get_theme_mod('solar_services_button_text2', 'More About Us');
                          $solar_services_button_text2link = get_theme_mod('solar_services_button_text2link', ''); 
                          if (empty($solar_services_button_text2link)) {
                              $solar_services_button_text2link = get_permalink();
                          }
                          if ($solar_services_button_text2 || !empty($solar_services_button_text2link)) { ?>
                            <?php if (get_theme_mod('solar_services_button_text2', 'More About Us') != "" ) { ?>
                              <a class="me-3 mb-2 btn2" href="<?php echo esc_url($solar_services_button_text2link); ?>">
                                <?php echo esc_html($solar_services_button_text2); ?>
                                <span class="screen-reader-text"><?php echo esc_html($solar_services_button_text2); ?></span>
                              </a>
                            <?php } ?>
                        <?php } ?>
                      </div>
                    </div>
                  </div>
                </div>
              <?php endwhile; wp_reset_postdata(); ?>
            <?php } ?>
          </div>
        </div>
        <div class="clear"></div>
    </section>
  <?php } ?>

<?php
    $solar_services_service_hidepageboxes = get_theme_mod('solar_services_service_hidepageboxes', true);
    $solar_services_blog_cat = get_theme_mod('solar_services_blog_cat');
    if( $solar_services_service_hidepageboxes && $solar_services_blog_cat){
  ?>
  <section id="blog" class="my-5">
    <div class="container">
      <div class="blog_bx mx-lg-5 px-lg-5">
        <?php if ( get_theme_mod('solar_services_headingtext1') != "") { ?>
          <h2 class="subhed mb-3"><?php echo esc_html(get_theme_mod('solar_services_headingtext1','solar-panels')); ?></h2>
        <?php }?>
        <?php if ( get_theme_mod('solar_services_headingtext_para') != "") { ?>
          <h3 class="mb-3"><?php echo esc_html(get_theme_mod('solar_services_headingtext_para','solar-panels')); ?></h3>
        <?php }?>
      </div>
      <div class="row">
        <?php if( get_theme_mod('solar_services_blog_cat',false) ) { ?>

        <?php $solar_services_queryvar = new WP_Query(
          array( 
            'cat' => esc_attr(get_theme_mod('solar_services_blog_cat',false)),
            'posts_per_page' => esc_attr(get_theme_mod('solar_services_blog_count',3,true))
          )
        );
        while( $solar_services_queryvar->have_posts() ) : $solar_services_queryvar->the_post(); ?>
        <div class="col-lg-4 col-md-6 service-box my-5">
          <?php the_post_thumbnail( 'full' ); ?>
          <div class="blog-content<?php if (!has_post_thumbnail()) echo ' no-thumbnail'; ?>">
            <div class="row">
              <div class="col-lg-9 col-md-9 col-9 align-self-center">
                <h4 class="fw-bolder my-0"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
              </div>
              <div class="col-lg-3 col-md-3 col-3 align-self-center">
                <div class="blog-btn">
                  <a href="<?php the_permalink(); ?>"><i class="fas fa-chevron-right"></i></a>
                </div>
              </div>
            </div>
          </div>
        </div>
        <?php endwhile; wp_reset_postdata(); ?>
        <?php } ?>
      </div>
    </div>
  </section>
<?php } ?>

</div>

<?php get_footer(); ?>