Kamis, 06 Maret 2014

Remove index.php From URL - CodeIgniter

Setelah sekian lama, akhirnya dapet kerjaan pake CI --lagi--. hiks hiks.. *terharu
Tapi jadinya banyak yang lupa :D. sampe2, cukup lama juga muter2 nyari 'beberapa' halaman yang jadi 'Not Found' dilocal, update dari SVN ok, no conflict but why in my local it doest work?
yak cek bebicek url dan config, base url dan index nya. sudah yakin bener donk, tapi mengapa masih Not Found?? akhirnya curiga sama index pagenya. dan bener aja -__-

jadi begini pemirsah, untuk ngilangin index.php di CI anda cukup masukin beberapa baris script di file .htaccess
jangan lupa .htaccessnya disimpan di rootnya yaa.. alias satu direktory sama folder system dan application.
here is the script you should put in your .htaccess :

# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn’t true it sends the
# request to index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

dan jangan lupa untuk kosongkan $config['index_page'] = ''; pada file config.php anda.
selamat mencoba ^^

Senin, 06 Januari 2014

'Console' is Undefined Error for Internet Explorer

Beberapa waktu lalu disuruh mbenerin bug dari suatu aplikasi dikantor. Berhubung programmer yang bikin udah caw alias minggat, alias resign jadilah dilimpahkan ke saya. hehe ya gtu deh kerjaan saya sekarang, lebih banyak suruh mbenerin bug dan nambah fitur dari pada bikin baru. 

oke langsung aja, problemnya ada satu javascript yang error 'Console' is Undefined Error for Internet Explorer ketika dijalankan di IE. tapi di browser2 lain gak ada masalah. setelah gugling iseng2 nemulah disini.
Intinya tambahkan kode berikut pada bagian atas halaman :

if (!window.console) console = {log: function() {}};

kode tersebut berfungsi untuk mengecek apakah ada console yang telah diset, kalo enggak maka kode tersebut akan menset kedalam sebuah objek berupa fungsi kosong yang disebut log. dengan cara ini window.console tidak pernah benar2 terdefinisi. 

ya kira2 begitu, cukup sekian dan terima kasih.
si yu babay :p

Jumat, 12 Juli 2013

Examples for pager_query()

Syntax :
pager_query($query, $limit = 10, $element = 0, $count_query = NULL)

Table format Pager :
 if you want to display the data as a table format, you can use the following example:
/**To get the records, first we need to have a query for total records. I am taking an example of node table records.**/
$sql_count = "SELECT count(*) FROM node";
 $sql = pager_query("SELECT * FROM node",5,0,$sql_count); //5 - limited pages to show
 $nodeContent = array();
 while($row = db_fetch_object($sql)){
    $createdDate = date('jS M, Y',$row->created);
    $nodeContent[] = array( $row->nid, $row->title, $createdDate);
 }
 // to set the table header titles
 $tableHeader = array('Nid','Title','Date');
 // to get the table format
 $output .= theme('table', $tableHeader, $nodeContent);
 // get the pager
 $output .= theme('pager', NULL, 5, 0);
 return $output;
- from here : http://www.drup-all.com/blog/examples-pagerquery