[eluser]Unknown[/eluser]
Hello,
Im having problems with pagination to work right. The adressing works fine but cant force the pagination links to display
Here is the controller
Code:
public function listing(){
$data['content']='contentList';
$data['row']="";
$config['per_page'] = 10;
$config['num_links'] = 5;
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
if($this->uri->segment(2)!=""){
$this->load->model('datamodel');
$data['row']=$this->datamodel->getByOs($this->uri->segment(2), $config['per_page'],$this->uri->segment(3));
$config['base_url'] = base_url().'list/'.$this->uri->segment(2);
}
/*
if($this->uri->segment(2)!="" && $this->uri->segment(3)!=""){
$this->load->model('datamodel');
$data['row']=$this->datamodel->getByCat($this->uri->segment(2), $this->uri->segment(3));
$config['base_url'] = base_url().'list/'.$this->uri->segment(2).'/'.$this->uri->segment(3);
}
if($this->uri->segment(2)!="" && $this->uri->segment(3)!="" && $this->uri->segment(4)!=""){
$this->load->model('datamodel');
$data['row']=$this->datamodel->getBySubCat($this->uri->segment(2), $this->uri->segment(3), $this->uri->segment(4));
$config['base_url'] = base_url().'list/'.$this->uri->segment(2).'/'.$this->uri->segment(3).'/'.$this->uri->segment(4);
}
*/
$config['total_rows'] = count($data['row']);
$this->pagination->initialize($config);
$this->load->view('main', $data);
}
Here is model
Code:
public function getByOs($os, $num, $offset){
//$q = $this->db->query("SELECT * FROM programs WHERE osForDb='".$os."'");
$q = $this->db->get_where('programs', array('osForDb' => $os), $num, $offset);
if($q->num_rows()>0){
foreach($q->result() as $row){
$data[]=$row;
}
return $data;
}
}
and here is the view
Code:
if(!empty($row)){
foreach($row as $r){
echo $r->name."<br/>";
}
}
echo $this->pagination->create_links();
Im rly newbie to codeigniter yet, guess its some totally dumb thing. Thx for help in advance.