1

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?

1 Answer 1

1

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';
Sign up to request clarification or add additional context in comments.

1 Comment

that routing is what i need, cool_news is a variable and can't make statis function for it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.