[eluser]alpcan[/eluser]
this great work in my default controller. But my category page, it doesn't work.
My codes.
pagination autoloaded.
controller kategori.php
Code:
<?php
class kategori extends Controller
{
function __construct()
{
parent::Controller();
// mPage sınıfı layout tanımlaması
$this->mpage->base("layout");
}
function oku()
{
$config['base_url'] = base_url().'/kategori/'.$this->uri->segment(3).'/';
$config['total_rows'] = $this->db->count_all('sorular');
$config['per_page'] = '2';
$config['uri_segment'] = '4';
$this->pagination->initialize($config);
$sayfala = array($config['per_page'],$config['uri_segment']);
$data['sorular'] = $this->sorumodel->sorular(1, $sayfala, $this->uri->segment(3));
$data['katlar'] = $this->katmodel->katlar();
$data['ayarlar'] = $this->ayarmodel->ayarlar();
$this->mpage->render("soru/kategori", $data);
}
}
?>
My model
Code:
<?php
class sorumodel extends Model
{
function __construct()
{
parent::Model();
}
function sorular($siralama = "", $sayfala = array(), $kat_sef = "")
{
if($siralama == 0)
{
$this->db->order_by("baslik", "asc");
}
if($siralama == 1)
{
$this->db->order_by("id", "desc");
}
if($sayfala)
{
$this->db->limit($sayfala[0], $sayfala[1]);
}
if($kat_sef)
{
$katQuery = $this->db->get_where("kategoriler", array("sef"=>$kat_sef));
if($katQuery->num_rows() > 0)
{
$kat = $katQuery->row();
$query = $this->db->get_where("sorular", array("KAT_ID"=>$kat->id));
if($query->num_rows() > 0)
{
$result = $query->result();
}
else
{
$result = FALSE;
}
}
else
{
show_404();
}
}
else
{
$query = $this->db->get("sorular");
if($query->num_rows() > 0)
{
$result = $query->result();
}
else
{
$result = FALSE;
}
}
return $result;
}
function soru($sef)
{
$sef = $this->guvenlik->sec($sef);
if($sef == "")
{
show_404();
}
else
{
$query = $this->db->get_where("sorular", array('sef'=>$sef));
if($query->num_rows() > 0)
{
$result = $query->row();
}
else
{
show_404();
}
}
return $result;
}
}
?>
and my view
Code:
<h2><?=$this->katmodel->sef2baslik($this->uri->segment(3));?> kategorisindeki sorular</h2>
<? if($sorular == FALSE): ?>
Hiç soru yok!
<? else: ?>
<? foreach($sorular as $soru): ?>
<h4><a >sef?>"><?=$soru->baslik?></a></h4>
<p><?=$soru->icerik?></p>
<hr>
<? endforeach ?>
<?=$this->pagination->create_links();?>
<? endif ?>
My codes turkish but i'm sure you'll understand their purpose...
I used htaccess..
RewriteEngine on
RewriteRule ^kategori/(.*)$ /project/index.php/kategori/oku/$1 [L]
RewriteRule ^soru/(.*)$ /project/index.php/soru/oku/$1 [L]
RewriteCond $1 !^(index\.php|robots\.txt|user_guide|media|scaffolding)
RewriteRule ^(.*)$ /project/index.php/$1 [L]