i have that code. i don't get why they use slug. can someone explane? i search what is the mean of slug. I think It is like a variable, I can chance it's name. but what is the importance of slug? yazi_model.php model->
<?php
class Yazi_model extends CI_Model{
public function __construct(){
$this->load->database();
}
public function getir_yazilar($slug = FALSE){ //why slug should be false? why we use slug for it?
if($slug === FALSE){ //is this 'if' is necessary? I can just write last code and it will work.
$query = $this->db->get('yazilar');
return $query->result_array();
}
$query = $this->db->get_where('yazilar',array('slug' => $slug));//why slug?
return $query->row_array();
}
}
Yazilar.php controller->
<?php
class Yazilar extends CI_Controller{
public function index(){ //why not use slug
$veri['baslik'] = 'Son yazılar';
$veri['yazilar'] = $this->yazi_model->getir_yazilar();
$this->load->view('tema/header');
$this->load->view('yazilar/index',$veri);
$this->load->view('tema/footer');
}
public function detay($slug = NULL){ //why slug
$veri['yazi'] = $this->yazi_model->getir_yazilar($slug); //why slug
if(empty($veri['yazi'])){
show_404();
}
$veri['baslik'] = $veri['yazi']['baslik'];
$this->load->view('tema/header');
$this->load->view('yazilar/detay',$veri);
$this->load->view('tema/footer');
}
}