<?php
$this->load->view("top_application");
$fieldType = $this->session->userdata('field_type');
?>
<section class="dir-alp dir-pa-sp-top">
  <div class="container">
  <div class="row">
<div class="pg-list-1-left1"> <h1>Blogs</h1>
        <div class="dir-alp-tit">
          <ol class="breadcrumb">
            <li><a href="<?php echo site_url(); ?>" title="Return to Home"><?php echo ($this->session->userdata('lang') == 'p') ? $this->lang->line('home') : 'Home'; ?></a></li>
        <li class='active'><?php echo ($this->session->userdata('lang') == 'p') ? $this->lang->line('blog') : 'Blog'; ?></li>        
            </ol>
        </div>
      </div>
      </div>
</div>

<div class="container">
<div class="row">
<div class="dir-alp-con">
<div class="col-md-9 dir-alp-con-right list-grid-rig-pad left_right_pad blog_left_pad">
<?php
if (is_array($res) && !empty($res)) {
foreach ($res as $key => $val) {
  //echo $val['article_image'].'<br>';
?>
<div class="blog-single">
<div class="col-md-5">
<div class="blog-img"><a href="<?php echo site_url($val['friendly_url']); ?>"><img class="img-responsive" src="<?php echo get_image('blog', $val['article_image'], '807', '417', 'R'); ?>" title="<?php echo $val['article_title' . $fieldType]; ?>" alt="<?php echo $val['article_title' . $fieldType]; ?>"></a> </div>
</div>
<div class="col-md-7">
<div class="page-blog">
<h3><a href="<?php echo site_url($val['friendly_url']); ?>" title="<?php echo $val['article_title']; ?>"><?php echo $val['article_title' . $fieldType]; ?></a></h3>
<ul class="list-inline">
<li><i class="fa fa-user"></i> By: <?php echo $val['blog_author']; ?> | </li>
<li><i class="fa fa-calendar"></i> <?php echo getDateFormat($val['post_date'],3); ?></li>
</ul>
<p><?php echo char_limiter($val['short_desc' . $fieldType],450); ?></p> 
<a class="waves-effect waves-light btn-large full-btn" href="<?php echo site_url($val['friendly_url']); ?>" title="<?php echo $val['article_title' . $fieldType]; ?>"><?php echo ($this->session->userdata('lang') == 'p') ? $this->lang->line('read_more') : 'Read More'; ?></a> 
</div>
</div>
</div>
<?php
}
}
?>       
<ul class="list-inline list-unstyled"><?php echo $page_links; ?></ul>
</div>
<div class="col-md-3 dir-alp-con-left">
<div class="dir-alp-l3 dir-alp-l-com">
<h4><?php echo ($this->session->userdata('lang') == 'p') ? $this->lang->line('categories') : 'Category'; ?></h4>
<div class="dir-hom-pre dir-alp-left-ner-notb">
<ul>
<?php
$resGro = $this->db->query("SELECT * FROM wps_categories WHERE status = '1' AND parent_id = '0'")->result_array();
foreach ($resGro as $sideval) {
 ?>
<li><a href="<?php echo site_url($sideval['friendly_url']); ?>" title="<?php echo $sideval['category_name' . $fieldType]; ?>"> <?php echo $sideval['category_name' . $fieldType]; ?></a></li>
<?php
}
?>
</ul>

<div class="dir-alp-l3 dir-alp-l-com">
<h4><?php echo ($this->session->userdata('lang') == 'p') ? $this->lang->line('similar_blogs') : 'Similar Blogs'; ?></h4>
<div class="dir-alp-l-com1 dir-alp-p3 you_may_like">
<?php
$popular = $this->db->query("SELECT * FROM wps_blog WHERE article_id ORDER BY rand() LIMIT 20")->result_array();
foreach ($popular as $popular) {
?>
<div class="right_news">
<a href="javascript:void()">
<div class="image">
<img class="img-responsive" src="<?php echo get_image('blog', $popular['article_image'], '', '', 'R'); ?>" alt="">
</div>
</a>
<h5><a href="<?php echo site_url($popular['friendly_url']); ?>"><?php echo $popular['article_title']; ?></a></h5>
<!--<ul class="list-inline">
<li><i class="fa fa-user"></i> By: <?php echo $popular['blog_author']; ?> | </li>
<li><i class="fa fa-calendar"></i> <?php echo $popular['post_date']; ?></li>
</ul>
<p><?php echo $popular['short_desc']; ?></p>-->
</div>
<?php
}
?>               
</div>
</div>
     
     
     <div class="sidebar-widget outer-bottom-xs hidden">
              <h3 class="section-title"></h3>
              <ul class="nav nav-tabs">
                <li class="active"><a href="#popular" data-toggle="tab"><?php echo ($this->session->userdata('lang') == 'p') ? $this->lang->line('popular_post') : 'popular post'; ?></a></li>
                <li><a href="#recent" data-toggle="tab"><?php echo ($this->session->userdata('lang') == 'p') ? $this->lang->line('recent_post') : 'recent post'; ?></a></li>
              </ul>
              <div class="tab-content" style="padding-left:0">
                <div class="tab-pane active m-t-20" id="recent">
                  <?php
                  $recent = $this->db->query("SELECT * FROM wps_blog WHERE article_id ORDER BY rand() LIMIT 20")->result_array();

                  foreach ($recent as $recent) {

                    //trace($val);
                    ?>
                    <div class="blog-post"> <img class="img-responsive" src="<?php echo get_image('blog', $recent['article_image'], '222', '115', 'R'); ?>" alt="<?php echo $recent['article_title']; ?>" title="<?php echo $recent['article_title']; ?>">
                      <h4><a href="<?php echo site_url($recent['friendly_url']); ?>"><?php echo $recent['article_title']; ?> </a></h4>
                      <span class="author"><?php echo $recent['blog_author']; ?></span> <span class="date-time"><?php echo $recent['post_date']; ?></span>
                      <p><?php echo char_limiter($recent['short_desc'], 100); ?></p>
                    </div>
                    <?php
                  }
                  ?>
                </div>
              </div>
            </div>
            
            
      <!--==========End Sub Category Filter============-->
</div>
       </div>
        </div>	
		 </div>
		  </div>	
    </div>
</section>

<!-- ============================================================= FOOTER ============================================================= -->
<?php $this->load->view("bottom_application"); ?>
