CodeIgniter PHP : (Cara Membuat Redirect Time Codeigniter)


Halo-halo lagi buat sahabat setia Belajar Pintar PHP, sekarang saya ingin berbagi lagi sebuah ilmu baru yang saya dapat dari hasil searching di google. Yaitu mengenai penambahan wait time ( Loading Time ) yang terdapat pada fungsi redirect di Codeigniter.

Wait time adalah waktu tunggu atau waktu yang dibutuhkan untuk melakukan redirect.Misal kita redirect ke page 1, dan wait time yang kita set yaitu 5 detik, jadi sebelum redirect ke halaman 1, kita harus menunggu selama wait time tersebut.

Secara default fungsi redirect di Codeigniter tidak memberikan wait time.Oleh karena itu kita harus menambahkan sendiri.

Berikut langkah-langkahnya :


Buka file url_helper.php yang terdapat di folder Codeignitermu/system/helpers/
Kemudian cari baris berikut :
 
if ( ! function_exists('redirect'))
{function redirect($uri = '', $method = 'location', $wait_time = 0,_
_$http_response_code = 302)
 {
 switch($method)
 {
 case 'refresh'    : header("Refresh:".$wait_time.";url=".site_url($uri));
 break;
 default            : header("Location: ".site_url($uri), TRUE, $http_response_code);
 break;
 }
 exit;
 }
}


Dan tambahkan dengan kode yang berwarna Biru di atas..Nilai wait time (satuan detik) dapat di-set sesuka hati.Tapi jangan terlalu lama.

Sekarang , redirect Codeigniter bisa digunakan dengan fitur wait time.

NB: Untuk menggunakan helper redirect codeigniter dengan cara berikut :
 
redirect ('lokasi_redirect_anda','refresh');


Cukup sekian tutorial kali ini, saya harap anda bisa menggunakannya dengan baik dan benar, dan tetap saya ingatkan, jangan lupa untuk like posting saya ini, dan juga komentarnya. Terimakasih.

13 Komentar

  1. Makasih gan panduannya
    kunjungin blog saya ya http://nawi-van.blogspot.com

    BalasHapus
  2. Sama-sama gan atas kunjungannya ,,

    akan saya kunjungi balik

    BalasHapus
  3. mksh gan buat tutornya

    BalasHapus
  4. gan,makasih ya panduannya,mudah dimengerti ^^
    www.rajalistrik.com

    BalasHapus
  5. Escort service in Jaipur with high profile Younger girls
    It is amazing to see how the whole part of our Jaipur girls take pride in their appearance and personal tidiness. They put their best foot forward and do everything they can to make sure that the girls are happy. They want to ensure that their clients are happy. We are not a standout Jaipur-escort, but we are committed to making sure customers return for more activities. Totally attracted purchaser businesses, escorts, and association prices. Jaipur escort association outperforms undertaking as if they have never existed in the most fundamental pervasiveness.
    Call/Whatsapp - 8239556555
    https://www.nishasharma.in/
    https://sexycallgirljaipur.com/
    https://priyachauhan.co.in/
    https://arohigupta.com/
    https://shivanikaur.in/
    Escort in Mahipalpur
    Escorts in Goa
    Escorts in Jaipur
    Escort in Faridabad

    BalasHapus

  6. Usually I never comment on article but your article is so convincing that I never stop myself to Real Leather. chihuahua puppy for sale near me best chihuahua puppies for sale hairless cats for sale Despite the fact that they are very intelligent, am finding it very difficult getting them to mate chihuahua for sale
    chihuahua for sale near me


    BalasHapus

  7. Totally loved your article. Looking forward to see more more from you. sphynx cat for sale Meanwhile feel free to surf through my website while i give your blog a read. chihuahua puppies for sale near me Are you also lokking to adopt chihuahua puppies sphynx kitten for sale, teacup chihuahua for sale

    BalasHapus
Lebih baru Lebih lama