Welcome Guest, Not a member yet? Register   Sign In
Pagination with variable uri
#1

[eluser]Anonymous[/eluser]
Hi,

I'm new to codeigniter and just getting a grip on it.

I'm stuck with the following problem:
I have a large products function that wil check if a company/category/both etc is given in the uri.

Like this:

Code:
function producten()
  {
    if ($this->uri->total_segments() == 3)
    //Only a company or a category is given
    {
      if ($companyid = $this->company_model->getCompanyIdByName($segment3))
      //only company is given
      { code here
      }
    }
//more if statements here

How to use pagination with this setup ? When the pagination class adds an /2 to the uri, my IF statements won't run.
#2

[eluser]JoostV[/eluser]
You may want to try the pagination automated library. Basically, once you load the library you have instant pagination. It just assumes that you use the following naming convention for paging: Page/offset. You need to have this somewhere (anywhere) in your URI.

Two advantages here: pagination with less coding and configuration, and you can run a simpleb check on your uri. If segment 3 is an integer, you can assume only show a company or category is given. If it it is a string ('Page'), run your if statements.
#3

[eluser]Anonymous[/eluser]
$Segment3 is always a string, so that construction wont work on that :/




Theme © iAndrew 2016 - Forum software by © MyBB