title: MVC - Looking for a better way to get from URL to view
body: <p>The below example shows how I am currently doing things.</p>
  
  <p>index.php includes index_controller.php then index_template.php.</p>
  
  <p><strong>index_controller.php</strong></p>
  
  <pre class="lang-php prettyprint-override"><code>$uri = explode('/', $_SERVER['REQUEST_URI']);
  $action = $uri[1];
  $call = $uri[2];
  
  $tmp = explode('?', $call);
  $call = $tmp[0];
  
  $call = preg_replace('/-/', ' ', $call);
  
  switch ($action) {
      case "about":
          $page = "about.inc.php";
          $title = "About Us";
          $description = "Description of page";
          break;
      case "category":
          try {
              //PDO query to make sure category ($call) exists
          }
          catch (PDOException $e) {
              logError($e-&gt;getMessage());
          }
          if (query-&gt;rowCount() &lt; 1) {
              $page = "404.inc.php";
              $title = "404 Error";
          }
          else {
              //Meta information for selected category pulled from DB and put into variables.
              $page = "category.inc.php";
          break;
      default:
          $page = "404.inc.php";
          $title = "404 Error";
  }
  </code></pre>
  
  <p>The above example shows 2 of around 12 different page options in the switch statement.  A simple request (about) and a more complex request (category).  </p>
  
  <p><code>index_template.php</code> has all my head, body, and footer HTML.  It sets the meta data for the page, sets up the sites structure, and includes whatever file the <code>$page</code> variable is set to in <code>index_controller.php</code></p>
  
  <p>Using the above example, if someone goes to <strong>mysite.com/category/books</strong> <code>index_controller.php</code> will see if the books category exists and if it does <code>category.inc.php</code> will be included.</p>
  
  <p><code>category.inc.php</code> does another PDO query to get all the items and information required to display a list of items for the selected category.  It also includes a template file to structure the display of the returned items.</p>
  
  <p>I am trying to achieve a MVC type structure (without using a framework like Codeigniter or CakePHP), but I don't really have the model end down.</p>
  
  <p>How can I get the user from the URL to the view using classes and/or functions instead of all the includes I am currently using?</p>
  
  <p>If you feel I didn't do a good job explaining the other files mentioned I can provide code examples from those files as well.</p>
  
  <p>Any help, input, or suggestions will be greatly appreciated.</p>
  
  <p>EDIT: Clarified question as per comment below.</p>