CodeIgniter Forums
[SOLVED] query /w pagination - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: [SOLVED] query /w pagination (/showthread.php?tid=40490)

[SOLVED] query /w pagination - El Forum - 04-10-2011

Is it possible to pass a variable/string through an uri segment to a controller, to modify a query?

What I want to do, if someone clicks on "x category" anchor link in my blog, I want to filter the query (my posts), with pagination remain working.

Example link:

anchor('site/posts/2', '') - where 2 is the category_id

How to mix the category param and pagination numbers?

Thank you

[SOLVED] query /w pagination - El Forum - 04-10-2011

Have you looked at $this->uri->segment(n) to pull segments from the URL? For example:
$category = $this->uri->segment(3);

Then you can filter your data for that category. You may need to change the number 3 to fit your specific URL.

[SOLVED] query /w pagination - El Forum - 04-10-2011

When setting the base_url of the pagination class in the controller you can first check for the existence of the category number.

$config['base_url'] = '';
if ($cat_id) $config['base_url'] .= $cat_id . '/';


[SOLVED] query /w pagination - El Forum - 04-10-2011

Thanks, bit same as micflan solution I set a default value for category, and put it to base_url config, and to segment 3, and pagination to segment 4.
So now it works!