Welcome Guest, Not a member yet? Register   Sign In
Is this possible with routes?
#1

[eluser]marcusahle[/eluser]
I want when someone goes to example.com/index.php/anything_here 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, example.com/index.php/anything_here/any_number will route to the same posts/posts for pagination.

But then if someone goes to example.com/index.php/anything_here/anything_else_that_isn't_a_number_here it will route to class posts function view_post

Oh yea, I would also like example.com/index.php/anything_here/add to go to posts/add

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

I thought I could try this:
Code:
$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
Code:
$route[':any/add'] = 'posts/add';

Basically my ultimate goal is:
have domain.com/category list posts in that category
have domain.com/category/2 go to page two of the pagination
have domain.com/category/add add a post under that category
have domain.com/category/post_title 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?
#2

[eluser]marcusahle[/eluser]
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.
#3

[eluser]lwliang061[/eluser]
These things looked pretty good, and some that I can learn, and I hope to learn more on it!




Theme © iAndrew 2016 - Forum software by © MyBB