Tutorial Kohana 3

Tutorial Koahan 3

jquery dan codeigniter

langsung aja ah gan...
baru berhasil tadi sore...

karena kita pake datatype json jadi kita harus tambahin helper json di codeigniter kita..
Download disini

kopiin isi file donlotannya di "system/helper"

bikin tablenya contoh:

CREATE TABLE `konsep` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nm_konsep` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=latin1;

INSERT INTO `konsep` (`id`,`nm_konsep`) VALUES
(1,'Seni/Budaya'),
(2,'Sejarah'),
(3,'Komunikasi'),
(4,'Profesi'),
(5,'Kuliner'),
(6,'Proses'),
(7,'Go Green'),
(8,'Back To Nature');


Bikin Controller

file controllers/konsep.php
class konsep() extends Controller{
   public function konsep(){
      parent::Controller;
   }
   public function index(){
      load-> vars($data);
      $this->load->view('admin');
   }
   public function getlistkonsep(){
      $sidx = $this->input->post('sidx');
      $sord = $this->input->post('sord');
      $page = $this->input->post('page');
      $limit = $this->input->post('rows');
      $this->load->helper('json');
      $konsep=$this->mkonsep->gridcountkonsep();
      $count=count($konsep);
      if( $count > 0 ) {
         $total_pages = ceil($count/$limit);
      } else {
         $total_pages = 0;
      }
      if ($page > $total_pages) $page=$total_pages;
      $start = $limit*$page - $limit;
      if ($start<0) $start=0;  $row=$this->mkonsep->gridkonsep($sidx,$sord,$start,$limit);
      $response['page'] = $page;
      $response['total'] = $total_pages;
      $response['records'] = $count;
      $response['start'] = $limit*$page - $limit;
      $i=0;
      $rowid=0;
      foreach ($row as $r) {
         $response['rows'][$i]['no']=$r["id"];
         $response['rows'][$i]['cell']=array($r['id'],$r['nm_konsep']);
         $i++;
      }
      echo json_encode($response);
   }
}

Bikin Modelnya

file models/mkonsep.php
class mkonsep() extends Model{
    public function mkonsep(){
        parent::Model;
    }

    function gridkonsep($idx,$ord,$start,$limit) {
  $data = array();
  $this-> db-> select('*');
  $this-> db-> from('konsep');
  $this->db->order_by($idx,$ord); 
  $this->db->limit($limit,$start);
  $Q = $this-> db-> get();
  if ($Q-> num_rows() > 0){
  foreach ($Q-> result_array() as $row){
   $data[] = $row;
  }
  }
  $Q-> free_result();
  return $data;
    }

    function gridcountkonsep(){
     $data = array();
  $this-> db-> select('*');
  $this-> db-> from('konsep');
  $Q = $this-> db-> get();
  if ($Q-> num_rows() > 0){
  foreach ($Q-> result_array() as $row){
   $data[] = $row;
  }
  }
  $Q-> free_result();
  return $data;
    }
}

bikin viewnya

filenya views/admin.php

//di viewnya tambahin css dan javascript yang dibutuhin

//cssnya yg di load

<link rel="stylesheet" type="text/css" href="<?=base_url();?>css/theme/south-street/jquery-ui-1.7.2.custom.css"/>

<link rel="stylesheet" type="text/css" media="screen" href="<?=base_url();?>css/ui.jqgrid.css" />

<link rel="stylesheet" type="text/css" media="screen" href="<?=base_url();?>css/ui.multiselect.css" />



//javascript yg di load

<script type="text/javascript" src="<?=base_url();?>scripts/jquery-1.3.2.min.js"></script>

<script type="text/javascript" src="<?=base_url();?>scripts/jquery-ui-1.7.2.custom.min.js"></script>

<script src="<?=base_url();?>scripts/jquery.layout.js" type="text/javascript"></script>

<script src="<?=base_url();?>scripts/i18n/grid.locale-en.js" type="text/javascript"></script>

<script type="text/javascript">

$.jgrid.no_legacy_api = true;

$.jgrid.useJSON = true;

</script>

<script src="<?=base_url();?>scripts/jquery.jqGrid.min.js" type="text/javascript"></script>

<script src="<?=base_url();?>scripts/jquery.tablednd.js" type="text/javascript"></script>

<script src="<?=base_url();?>scripts/jquery.contextmenu.js" type="text/javascript"></script>

<script src="<?=base_url();?>scripts/ui.multiselect.js" type="text/javascript"></script>



//dan ini untuk menampilkan jqgridnya....

<table id="list2"></table>

<div id="pager2">

</div>



//javascript ini harus di taro setelah table yang diatas itu...

<script type="text/javascript">

   jQuery("#list2").jqGrid({

      url:'admin/getlistkonsep',

      datatype: "json",

      mtype : "post",

      autowidth:true,

      autoheight:true,

      colNames:['id','Konsep'],

      colModel:[

         {name:'id',index:'id', width:55},

         {name:'nm_konsep',index:'nm_konsep', width:90,sortable:false}

      ],

      rowNum:7,

      rowList:[7,14,21],

      pager: '#pager2',

      sortname: 'id',

      viewrecords: true,

      sortorder: "asc",

      caption:"List Konsep"

   });

   jQuery("#list2").jqGrid('navGrid','#pager2',{edit:false,add:false,del:false,search:false});

</script>

untuk pathnya.. di sesuaikan aja ya ma agan2 sekalian hihihi pasti bisa lah :)

sayang ya jqgrid jadi berbayar sekarang :(

good luck...

hierarcial mvc dengan codeigniter (modularity/hmvc)

langsung aja gan...


1. pastikan codeigniter udah bisa di akses dengan baik

2. donlot file2 yang di butuhin untuk hmvc disini

3. kopikan isi file yang didonlot ke direktori "library" di bawah direktori "application"

4. bikin direktori "modules" dibawah direktori "application"

5. bikin lagi direktori module yang di perlukan misalnya "admin" di bawah direktori "modules"

6. Di dalam direktori admin bikin lagi direktori "controllers" yang dan diisi file "admin.php"

isi dari file admin.php

class Admin extends Controller {
function Admin()
{
parent::Controller();
}

function index()
{
$this->load->view('welcome_message');
}
}
?>


7. masi didalam direktori admin bikin lagi direktori "views" dan diisi dengan file "welcome_message.php"
isinya sama kan seperti yang ada di folder views utama

8. coba akses webnya "http://localhost/programnya/index.php/admin" kalo welcome messagenya muncul berarti hmvcnya udah jalan.. good luck... :)

struktur direktorinya...

addons firefox buat web developer..

https://addons.mozilla.org/en-US/firefox/addon/271
https://addons.mozilla.org/en-US/firefox/addon/5648
https://addons.mozilla.org/en-US/firefox/addon/2104
https://addons.mozilla.org/en-US/firefox/addon/2290
https://addons.mozilla.org/en-US/firefox/addon/2076
https://addons.mozilla.org/en-US/firefox/addon/6149
https://addons.mozilla.org/en-US/firefox/addon/6455

install driver nvidia ubuntu kermic koala

langsung der ah...

udah beres install ubuntu... donlot dulu driver nvidia disitus resminya...
http://www.nvidia.com/Download/index.aspx?lang=en-us
sesuaikan dengan vga nvidianya....

kalo udah di donlot..
1. tekan ctrl+alt+F1 (untuk masuk ke konsol.. jangan di lakukan di terminal biasa)
2. login seperti biasa (kalo udah login... matiin dulu gdm-nya)
3. ketik statement ini "sudo /etc/init.d/gdm stop" enter ,tanpa petik
4. pindah ke direktori di mana file donlotan driver berada..
5. untuk install gunakan perintah sh "sudo sh NVIDIA-Linux-x86_64-190.42-pkg2.run" enter ikutin perintah2nya....
6. ketik statement ini "sudo /etc/init.d/gdm start" enter ,tanpa petik
7. tungguin sambil baca komik...

good luck...

ajax

CSS