<?php
/**
 * Template part for displaying page content in page.php
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package o66FsWp
 */
//PENSARE SOLUZIONE PER GLOBAL INDEX
//$index_count = 0;
//global $index_count;
global $index_count;
if ( $index_count  == 1 ) {
	$isEven          = true;
	$containerEvOrOd = 'container-even';
} else {
	$isEven          = false;
	$containerEvOrOd = 'container-odd';
};
if ($index_count === 0) {
    $isEven = false;
    $isFirst = true;
    $containerEvOrOd = 'container-first';
}
$col_big_pull   = '';
$col_small_push = '';
if ( $isEven === false ) {
	$col_big_pull   = ' col-md-pull-4 ';
	$col_small_push = ' col-md-push-8 ';
}


$heading_level = 1;
//$image         = get_the_post_thumbnail_url( get_the_ID(), 'rect' );
if ($index_count === null) {$image = get_the_post_thumbnail_url( get_the_ID(), o66_image_sizes::nocrop_container );}
$col_big       = 'col-md-8';
$col_small     = 'col-md-4';
if ( empty( $image ) ) {
	$col_big      = 'col-md-12';
	$col_small    = null;
	$col_big_pull = ' ';
}
global $scope_model_args;
$the_query = new WP_Query( $scope_model_args );

if ( $the_query->have_posts() ) {

	while ( $the_query->have_posts() ) { ; ?>
		<?php $the_query->the_post();
		//console_log($index_count);

		if ($index_count === null) {
			$isEven          = true;
			$containerEvOrOd = 'container-even';

        }

		if ($index_count === 1) {
			$isEven          = false;
			$containerEvOrOd = 'container-odd';

		}

		if ($index_count === 2) {
			$isEven          = true;
			$containerEvOrOd = 'container-even';

		}

		$col_big_pull   = '';
		$col_small_push = '';
		if ( $isEven === false ) {
			$col_big_pull   = ' col-md-pull-4 ';
			$col_small_push = ' col-md-push-8 ';
		}


		$heading_level = 1;
		$image         = get_the_post_thumbnail_url( get_the_ID(), 'rect' );
		$col_big       = 'col-md-8';
		$col_small     = 'col-md-4';
		if ( empty( $image ) ) {
			$col_big      = 'col-md-12';
			$col_small    = null;
			$col_big_pull = ' ';
		}
        $class_zero = '';
		$class_is_null = '';
		if ($index_count === null ) {
		    $col_small = null;
		    $col_big = 'col-md-12';
		    $class_zero =  ' class_zero ';
        }
		if ($index_count === null) {$acf_Image = get_field('main_image', get_the_ID());
			$thumb = $acf_Image['sizes'][ o66_image_sizes::nocrop_container ];
			$image = $thumb;
			//var_dump($thumb);
		}

		?>
		<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <div class="blok post-index__item-container">
            <div class="row row--post-index">
				<?php if ( ! empty( $col_small ) ) : ?>
                    <div class="<?php echo $col_small . $col_small_push; ?> hidden-sm hidden-xs">
                        <div class="blok img-responsive-container">
                            <img src="<?php echo $image; ?>" alt="<?php the_title(); ?>"/>
                        </div>
                    </div>
				<?php endif; ?>
                <div class="<?php echo $col_big . $col_big_pull; ?> col-grey <?php echo $containerEvOrOd.$class_zero; ?> ">
                    <div class="entry-content entry-content--post-index">
                        <div class="entry-header__title-container <?php echo $class_zero;?>">
							<?php o66fswp_the_extended_title( 'extended_title', 2 ) ?>
                            <div class="entry-header__entry-date"><i
                                        class="fa fa-calendar-o"></i> <?php echo get_the_date(); ?></div>
                        </div>
                        <div class="blok img-responsive-container hidden-lg hidden-md mar-bot">
                            <img src="<?php echo $image; ?>" alt="<?php the_title(); ?>"/>
                        </div>
                        <?php if ($index_count === null) : ?>
                            <div class="blok img-responsive-container mar-bot hidden-xs hidden-sm">
                                <img src="<?php echo $image; ?>" alt="<?php the_title(); ?>"/>
                            </div>
                        <?php endif; ?>
                        <p><?php echo get_the_excerpt(); ?></p>
						<?php if (!empty($image)) : ?>

						<?php endif; ?>
                        <div class="entry-content--post-index__button-container">
							<?php o66fpwp_a_button( get_the_permalink(), 'leggi tutto', '<i class="fa fa-arrow-circle-o-right"></i>' ); ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        </article>
	<?php //	array_push( $team_cats, get_field( 'team_category' ) );
		$index_count++;

	}


	function the_div($content) {
	    return "<div>${content}</div>";
    }
    function the_p($content) {
	    return "<p>${content}</p>";
    }
    $test = the_div(the_p('contenuto'));

}
?>
<div class="bottom-index-button home-bottom">
    <div class="entry-content--post-index__button-container">
		<?php $leggiTutte = get_field('tutte_le_news','options');
        o66fpwp_a_button( get_post_type_archive_link( 'post' ), $leggiTutte, '<i class="fa fa-clipboard"></i>',true  ); ?>
    </div>
</div>

