Jeff Davidson
Jeff Davidson

Reputation: 1929

URI and URL for CodeIgniter

I'm having a problem understanding the docs on the CodeIgniter website dealing with URI segments and URLs combined.

Lets say I have a site www.whatever.com/

And on my main page I have a link that when clicked on will go to www.whatever.com/news/test-story

Question is do I make a new controller just for the news or how is this link about to be gone to correctly?

Upvotes: 1

Views: 184

Answers (1)

Colin Brock
Colin Brock

Reputation: 21575

Using your example, whatever.com/news/story would map to a function called story in a controller called news:

class News extends CI_Controller {

    function story() {
        // get a news story
    }
}

Of course, CodeIgniter provides URI Routing in which you can "remap" URLs to other controllers and functions.

Upvotes: 3

Related Questions