title: creating dynamic page URLs with CI (routing) - a simple message board example
body: <p>I feel like I have enough experience with CI to finally start fooling around with creating a message board... Or at least thats what I thought, until I got stuck at generating dynamic pages based on subject names (slugs).</p>
  
  <p>So, I creating the controller/model/views and set up a form that submits the necessary info to the database.  I pulled the threads out and display them, and generate a link for each one based on the subject title...i essentially followed the CI tutorial, editing it to suit my needs.</p>
  
  <p>However, understanding the concept of generating dynamic page URLs is throwing me off.  I understand a lot better by hearing exactly whats happening during the process, and the codeigniter tutorial (news) doesnt explain it well. It simply tells you what to do and how, and not why. </p>
  
  <p>Anyone out there feel up to attempting to explain in greater detail, the process to code dynamic pages.</p>
  
  <p>What I mean by dynamic pages is :</p>
  
  <p><a href="http://your-site.com/news/1/hello-world" rel="nofollow">http://your-site.com/news/1/hello-world</a>
  http://your-site.com/news/1/foo-bar</p>
  
  <p>where hello world and foo bar.</p>
  
  <p>Here are some parts that confuse me:</p>
  
  <pre><code>&lt;?php
  
  class Pages extends CI_Controller {
  
      public function view($page = 'home')
      {
  
      }
  }
  </code></pre>
  
  <p>And heres the routing</p>
  
  <pre><code>$route['default_controller'] = 'pages/view';
  $route['(:any)'] = 'pages/view/$1';
  </code></pre>
  
  <p>what does $1 represent?  Any specific url that there?  When would you use $2? Is it built in code to CI, or can you use any variable?</p>
  
  <p>I'm sure the answer can get more detailed, but If someone could answer some of the above questions, i'm sure it'd be very helpful.</p>
  
  <p>With those questions answered, in theory, what should be done to produce a new page for a forum thread? </p>
  
  <p>Thanks!</p>