-1
私はそのコードを持っています。なぜ彼らがスラッグを使うのか分からない。誰かがexplaneできますか? スラグの平均は何ですか?私はそれが変数のようだと思う、私はそれが偶然かもしれない名前です。スラグの重要性は何ですか? yazi_model.phpモデル - >CodeigniterでSlugを使用する理由
<?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');
}
}
[CodeIgniterのに使用ナメクジ]の可能な重複(https://stackoverflow.com/questions/3305786/using-s lugs-in-codeigniter) –
有用なクラス:https://github.com/ericbarnes/CodeIgniter-Slug-Library – Alex