title: CodeIgniter: Load a different view based on screen width instead of creating a mobile version?
body: <p>I thought of loading a different view folder <code>m.view</code> instead of having <code>m.project_name</code>. I am "autoloading" the templates so I only have the following in the controller:</p>
  
  <pre><code>$this-&gt;load_views('home/index.php', $data);
  </code></pre>
  
  <p>And in <code>My_Controller.php</code>:</p>
  
  <pre><code>function load_views($view, $data = []) {
      // load m.view for mobile
      $this-&gt;load-&gt;view('templates/header'. $data);
      $this-&gt;load-&gt;view($view, $data);
      $this-&gt;load-&gt;view('templates/footer', $data);
  }
  </code></pre>
  
  <p>In my <code>footer.php</code>:</p>
  
  <pre><code>&lt;script&gt;
      if (screen.width &lt; 937) {
          window.location('http://localhost/m.project_name');
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>But think of being in <a href="http://localhost/project_name/controller/method/p1" rel="nofollow">http://localhost/project_name/controller/method/p1</a>, you'll be redirected to the default page.</p>