Controller/Parameter syntax?
I use CodeIgniter and let's say i build a blog where /posts
shows all posts, and开发者_如何转开发 /posts/cool_news
shows the article called cool_news
.
I know the first one would only need a controller called Posts
and a function called index()
. But how about the second example? how to get the second parameter which can be anything?
Using the default routing:
You create another action in the Posts controller called cool_news()
If you want it to be passed as an argument to the index()
action then you need to look at doing some custom routing.
This is untested but should look something like:
$route['posts/(:any)'] = 'posts/index/$1';
精彩评论