Welcome Guest, Not a member yet? Register   Sign In
Pagination doesn't work if the controller is inside the (sub)folder?
#1

[eluser]Unknown[/eluser]
I have a folder which name is "administrator" inside the "controllers" folder.
Inside the "administrator" folder i have a Test controller.
Inside this controller I want to use the pagination library.
The code looks like this:
Code:
<?php
class Test extends CI_Controller {
public function index() {
  $this->load->library("pagination");
  $config["base_url"] = base_url("administrator/test/index");
  $config["total_rows"] = $this->db->get("slideshow")->num_rows();
  $config["per_page"] = 2;
  $config["num_links"] = 5;

  $this->pagination->initialize($config);
  $data["query"] = $this->db->get("slideshow", $config["per_page"], $this->uri->segment(4));
  $this->load->view("administrator/test/test",$data);
}
}
?>
but when I go to localhost/mywebsite/administrator/test the pagination won't work.I have 15 records within the database, so it should have 8 pages. But it show me only 6 page, and always the first (1) page is active, the "next" link is not working, etc.
But if I make a new controller inside the "controllers" folder (url: localhost/mywebsite/test), which is almost the same, I just change the $config["base_url"] to base_url("test/index"); and $this->uri->segment(4) to $this->uri->segment(3) it works perfectly.
So my question is: can't i use pagination if my controller is inside the folder? | What is wrong with my code?
Thanks for the help.
#2

[eluser]treenef[/eluser]
Try changing the base_url config to include the sub folder.
#3

[eluser]joergy[/eluser]
Try using site_url() instead of base_url()

$config["base_url"] = site_url("administrator/test/index");
#4

[eluser]InsiteFX[/eluser]
Maybe because uri_segment(4) is empty.

localhost/mywebsite/administrator/test/1
#5

[eluser]Unknown[/eluser]
Still not working. :'(

Edit:
I added this line: $config['uri_segment'] = 4;
and looks like it works now.Smile




Theme © iAndrew 2016 - Forum software by © MyBB