<?php get_header('insidepages'); ?>

    <?php
    if (have_posts()){
        the_post();
            $newsPageId = get_ID_by_slug('pars-patent-news');
            $newsPage = get_post($newsPageId);

            if(get_field('icon_page', $newsPageId)) $icon = get_field('icon_page', $newsPageId);
            $title = $newsPage->post_title;
    }
    ?>

    <!-- Banner : Begin -->
    <div class="row no-margin slider">
        <div class="rounded">
            <div class="bannercontainer">
                <div class="banner" style="visibility:hidden">
                    <ul>
                        <!-- Slides : Begin -->
                        <?php
                        /*
                        *  Loop through Slider Repeater fields (From another $post ID)
                        */

                        if(get_field('sliders', $newsPageId) )
                        {
                            
                            while(has_sub_field('sliders', $newsPageId) )
                            {
                                if(get_sub_field('image_banner')) $image = get_sub_field('image_banner');

                        ?>
                                
                        <li data-transition="fade">
                            <img src="<?php echo $image; ?>" alt="" />
                            <div class="all-container row no-margin clr-0">
                                    <div class="container">
                                        <span class="caption sfl" data-speed="600" data-start="500" data-easing="easeIn"><img  src="<?php echo $icon; ?>" alt=""/></span>
                                        <h3 class="caption fade sfr" data-speed="600" data-start="600" data-easing="easeIn"><?php echo $title; ?></h3>
                                    </div>
                            </div>
                        </li>
                        
                        <?php
                            }
                        }
                        ?>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <!--  Banner : End -->

    <!-- Intro -->
    <div class="row no-margin">
        <div class="container margin_T_80 theme-padding"> 
            <p class="txt_al_j">
            <br />
            </p>
        </div>
    </div>
    <!-- /Intro -->



    <!-- News : Begin -->
    <div class="row no-margin"> 
        <div class="container theme-padding">

        <?php

            $args = array(
                'category_name' =>'news',
                'post_type' =>  'post',
                'posts_per_page' => 100,
                'orderby' => 'post_date',
                'order' => 'ASC'
            );
            $news = get_posts( $args );

            //var_dump($news);

            for($i=0; $i<count($news); $i++){
                $excerpt = wp_trim_words($news[$i]->post_content , 50, "...");
                $colorID = 1;
            ?>

            <div class="news-item clr-<?php echo $colorID; ?>">
                <div class="image-div col-sm-5 no-padding">
                        <a href="<?php echo get_permalink($news[$i]->ID); ?>"><img class="img-responsive center-block" alt="<?php echo $news[$i]->post_title; ?>" src="<?php the_img_url('large' , $news[$i]->ID); ?>"/></a>
                        <span><img src="<?php echo $icon; ?>" alt="<?php echo $news[$i]->post_title; ?>"/></span>
                        <div>
                            <a href="<?php echo get_permalink($news[$i]->ID); ?>">
                                EXPLORE NEWS <span></span>
                            </a>
                        </div>
                </div>
                <div class="text-div col-sm-7">
                    <h3><a href="<?php echo get_permalink($news[$i]->ID); ?>"><?php echo $news[$i]->post_title; ?></a></h3>
                    <p><?php echo $excerpt?></p>
                    <a href="<?php echo get_permalink($news[$i]->ID); ?>">Read More</a>
                </div>
            </div>
        <?php } ?>

        </div>  
    </div>
    <!-- News : End -->


                    
<?php get_footer('insidepages'); ?>