Menampilkan Data - PortalberitaFrontend Part04 - sopian aji

Terbaru

Sabtu, 18 April 2020

Menampilkan Data - PortalberitaFrontend Part04

1. application/controllers/BerandaUsr.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class BerandaUsr extends CI_Controller {
private $view  = "frontend/v_beranda/";
private $redirect = "berandausr";

public function __construct(){
parent::__construct();
//Load model
}

public function index(){
$data = array(
'read'=> ''
);
$this->template->load('frontend/template',$this->view.'read', $data);
}
}

3. application/controllers/BerandaUsr.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class BerandaUsr extends CI_Controller {
private $view   = "frontend/v_beranda/";
private $redirect  = "berandausr";

public function __construct(){
parent::__construct();
//Load model
}

public function index(){
$data = array(
'read'=> ''
);
$this->template->load('frontend/template',$this->view.'read', $data);
}
}

3. application/views/frontend/v_beranda/read.php
<?php
  $no=1;
  foreach ($beritaberanda->result_array() as $row) {
    if ($no%2==1){
 ?>
<!-- Single Post -->
<div class="col-12 col-md-6">
    <div class="single-blog-post style-3">
        <div class="post-thumb">
            <a href="#"><img src=" <?php echo base_url('assets/img_berita/'.$row['img_berita']) ?> " alt=""></a>
        </div>
        <div class="post-data">
            <a href="#" class="post-catagory"><?php echo $row['nama_kategori'] ?></a>
            <a href="<?php echo site_url('berandausr/beritalengkap/'.$row['id_berita']) ?>" class="post-title">
                <h6><?php echo substr($row['isi_berita'],0,200) ?>... berita lengkap</h6>
            </a>

        </div>
    </div>
</div>
<!-- EndSingle Post -->
<?php
}
else{
 ?>
<!-- Single Post -->
<div class="col-12 col-md-6">
    <div class="single-blog-post style-3">
        <div class="post-thumb">
            <a href="#"><img src="<?php echo base_url('assets/img_berita/'.$row['img_berita']) ?>" alt=""></a>
        </div>
        <div class="post-data">
            <a href="#" class="post-catagory"><?php echo $row['nama_kategori'] ?></a>
            <a href="<?php echo site_url('berandausr/beritalengkap/'.$row['id_berita']) ?>" class="post-title">
                <h6><?php echo substr($row['isi_berita'],0,200) ?>... berita lengkap</h6>
            </a>

        </div>
    </div>
</div>
<!-- EndSingle Post -->
<?php
}
$no++;
}
?>

4. application/views/frontend/v_beranda/beritalengkap.php
<div class="single-blog-post featured-post single-post">
    <div class="post-thumb">
        <a href="#"><img src="<?php echo base_url('assets/img_berita/'.$row['img_berita']) ?>" width="100%" alt=""></a>
    </div>
    <div class="post-data">
        <a href="#" class="post-catagory"><?php echo $row['nama_kategori'] ?></a>
        <a href="#" class="post-title">
            <h6><?php echo $row['judul_berita'] ?></h6>
        </a>
        <div class="post-meta">
            <p><?php echo $row['isi_berita'] ?></p>
            <div class="newspaper-post-like d-flex align-items-center justify-content-between">
            </div>

untuk lebih jelasnya bisa dilihat pada tutorial
1. Tutorial untuk menampilkan data pada frontend part01 klik disini
2. Tutorial untuk menampilkan data pada frontend part02 klik disini

Tidak ada komentar:

Posting Komentar