• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pagination problem, two segments

#1
[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>&lt;?=$this->katmodel->sef2baslik($this->uri->segment(3));?&gt; kategorisindeki sorular</h2>
&lt;? if($sorular == FALSE): ?&gt;
Hiç soru yok!
&lt;? else: ?&gt;
&lt;? foreach($sorular as $soru): ?&gt;
<h4><a >sef?&gt;">&lt;?=$soru->baslik?&gt;</a></h4>
<p>&lt;?=$soru->icerik?&gt;</p>
<hr>
&lt;? endforeach ?&gt;
&lt;?=$this->pagination->create_links();?&gt;
&lt;? endif ?&gt;

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]


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.