Showing posts with label codeigniter. Show all posts

gravatar

Codeigniter Fans : Remove index.php

Before you read this tutorial till end, please apologize me for my bad english, this is my first notes in english. I'm sorry guys.

Inspiring from railscasts.com, the Ruby on Rails Screencasts, and Nettuts, I'll try to make another tutorials by myself.

My first simple tutorials is to make a nice URL using Codeigniter, which is by default its contain index.php at URL. Such as http://example.com/index.php/articles/1.

We can remove the 'index.php' in Codeigniter by modified config file and adding some rule at .htaccess file. Config file is in config folder in application folder.

{your application name}/system/application/config/config.php

The htaccess file is in your root Codeigniter application. If you cannot find this file, it was hidden by default or maybe it is not yet created, you can created it first by create a new file using your favourite text editor, just don't add some filename, leave it blank, just add filetype .htaccess.

First, we should change the value index_page at config file to blank.

default value :
$config['index_page'] = "index.php";

change to :
$config['index_page'] = "";

And the last step is adding some rule in htaccess file.

RewriteEngine on
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ /{your application name}/index.php/$1 [L]

That's all for this sections, see you in the next tutorials. Hope this will help you.

wallohu'alambishowab

gravatar

Codeigniter 1.7.2 Release

Setelah menunggu lama dari rilis terakhir Codeigniter 1.7.1 bulan Februari 2009, akhirnya tim Ellislab kembali merilis Codeigniter 1.7.2, framework PHP open source yang bermodel MVC (model view controller), pada tanggal 11 September 2009 kemarin. Ellislab adalah developer yang membuat codeigniter dan juga CMS ExpressionEngine.


Tidak begitu banyak perubahan yang terjadi pada rilis terakhir ini, beberapa perubahan yang cukup menarik adalah penambahan Class Cart. Class Cart ini digunakan dalam pembuatan e-commerce, untuk menyimpan item pembelian customer. Untuk melihat update Codeigniter 1.7.2 langsung saja ke site resmi codeigniter.

Lambannya rilis ini, dikarenakan Ellislab mengutamakan pengembangan Expression Engine terlebih dahulu, karena memang CMS ini tersedia dalam tiga versi, Core Version yang gratis sampai yang harus membayar pada saat pertama kali yaitu Personal dan Commercial Version. Ini lah yang menjadi penyebab lahirnya Kohana, sebagai pengembangan Codeigniter oleh komunitas, dengan memakai kelebihan yang ada pada Codeigniter, sehingga lebih kecil dan tapi tetap tangguh.

Langsung aja download Codeigniter 1.7.2, dan rasakan perbedaannya.

wallohu'alambishowab

gravatar

Mencari Selisih Dua Tanggal di PHP

Untuk membuat selisih dua tanggal dalam PHP, gw pake cara ini :

Contoh, diketahui:
$q['check_in'] : Tanggal Masuk Hotel
$q['check_out'] : Tanggal Keluar Hotel

$start_day = (int) strftime("%d", strtotime($q['check_in']));
$start_month = (int) strftime("%m", strtotime($q['check_in']));
$start_year = (int) strftime("%Y", strtotime($q['check_in']));

$end_day = (int) strftime("%d", strtotime($q['check_out']));
$end_month = (int) strftime("%m", strtotime($q['check_out']));
$end_year = (int) strftime("%Y", strtotime($q['check_out']));

$diff = abs((mktime ( 0, 0, 0, $end_month, $end_day, $end_year) - mktime ( 0, 0, 0, $start_month, $start_day, $start_year))/(60*60*24));

Tinggal di echo aja $diff di phpnya. Selesai.

wallohu'alambishowab

gravatar

Get Last URI in CI

Ini fungsi buat Last URI dengan menggunakan library URI yang ada di Code Igniter

$ts=$this->uri->total_segments();
$offset = $this->uri->segment($ts);

atau bisa juga dengan :

$last = end($this->uri->segments);

hehe.. moga aja berguna.. sekalian biar ga susah nyari ntar klo gw perlu, maklum pelupa kronis..

wallohu'alambishowab