CodeIgniter Forums

Full Version: Is this possible with routes?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I want when someone goes to that it routes to class posts function posts. That page will show a list of posts under the category of whatever is put in uri segement 1.

Then I would like for pagination to be included. For example, will route to the same posts/posts for pagination.

But then if someone goes to't_a_number_here it will route to class posts function view_post

Oh yea, I would also like to go to posts/add

In the routes I have:
$route[':any/add'] = 'posts/add'; which works fine.

I thought I could try this:
$route[':any/add'] = 'posts/add';
$route[':any/:num'] = 'posts/posts';
$route[':any/:any'] = 'posts/view_post';
$route[':any'] = 'posts/posts';

but the only thing that works is the
$route[':any/add'] = 'posts/add';

Basically my ultimate goal is:
have list posts in that category
have go to page two of the pagination
have add a post under that category
have go to the view post page

I would have category and post_title parsed correctly for urls.

Am I on the right track or am I going about this the right way?

El Forum

Found the problem. It was because I had the class and function both named posts. I changed the function name and everything worked to perfection.

El Forum

These things looked pretty good, and some that I can learn, and I hope to learn more on it!