Question

Here Some Urls that a gathered, and i wondered, How to use Codeigniter to active such result, and what are they called?

  1. exemple.com/movies/action/some-title-that-i-want-to-implement/ (brings a post)
  2. exemple.com/movie-name/some-title-that-i-want-to-implement/ (brings a specificity post)
  3. exemple.com/movie-name (brings all the movie posts)
  4. exemple.com/comic-con/movies/some-title-that-i-want-to-implement/ (brings a post)
  5. exemple.com/comic-con/comics/some-title-that-i-want-to-implement/ (brings a post)
  6. exemple.com/some-title-that-i-want-to-implement/ (brings a post)
  7. exemple.com/2013/7/26/4558760/some-title-that-i-want-to-implement/ (brings a post)

The big question is how do you organize and think your application to have a similar result?

Était-ce utile?

La solution

How to use Codeigniter to active such result? Juat play with these:

  1. _remap() function in your controller
  2. URI Class
  3. Routes config.

Example:

exemple.com/movies/action/some-title-that-i-want-to-implement/ (brings a post)

Let say your default controller is home; then :

config/routes.php:

$route['(:any)'] = 'home/$1'

controller/home.php

class Home extends CI_Controller {

    function index()
    {
        //do somthing
    }

    public function _remap()
    {
       //play with uri segment here, i.e:
       if ($this->uri->segment(1) == 'movies')
       {
         //take 'movies' as parameter and use it
       }
       else
       {
        //you can be more creative than me
       }
    }
}

what are they called? I am not sure, I guess 'Virtual URI Mapping'.

how do you organize and think your application to have a similar result? There is no something special.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top