Welcome Guest, Not a member yet? Register   Sign In
Pagination class and uri's
#1

[eluser]Raymondddd[/eluser]
Hi,

I've a problem with the pagination class in combination with some uri's.

I use pagination for my category page, which one handle categories and subcategories

This is a part of de category controller:
Code:
public function readCategory($sParent, $sCategory = false) {
        
        $aData = array('parent' => $sParent, 'category' => $sCategory);

$aData will be send to the category model and de category model will return a list of products:
Code:
$this->category_model->readProductByCategory($aData, $config['per_page'], $this->uri->segment(3))

URL structure:
site.com/category/subcategory
site.com/category

Here is the problem: when i use my pagination in site.com/category, the url will be: site.com/category/10 (10 = offset) but my scripting sees it as a subcategory.

What is the best to prevent this? Would a check for numeric characters in the second parameter be enough?

Anyone a better idea?

Thank a lot!

Raymond
#2

[eluser]Mr. Pickle[/eluser]
Have a look here
http://codeigniter.com/wiki/Pagination_automated/

It's a script that loops all your uri segments in search for a pagination parameter.
e.g. if offset is linked to the offset you can have:
[...] /offset/10/ [...] anywhere in your url.
#3

[eluser]Raymondddd[/eluser]
Hi Mr. Pickle,

Tried this, but still the same problem. URL will be: site.com/category/page/2 where 'page' is the second parameter.
#4

[eluser]Mr. Pickle[/eluser]
You can change your routes for the category or have /category/index/page/2/ as the url.




Theme © iAndrew 2016 - Forum software by © MyBB