title: Codeigniter Front End Controller Not working with libraries
body: <p>I'm posting this after my hair has been ripped out, ran out of rum, and tried everything I can find on google. I've been developing a site using codeigniter which makes use of templates.  I've built the backend first and all is working properly there.  So now i've started on getting the front end working which is where I'm hitting the issue.  </p>
  
  <p>I've created a controller called <code>pages.php</code> which is going to parse the uri string of the current page, use my library to get the page data from the database, then display it.  My pages are all created through an editor on the back end and stored in the database. </p>
  
  <p>So here's the pages controller
  
  
  <pre><code>class Pages extends CI_Controller {
  
      public function __construct()
      {
          parent::__construct();
          $this-&gt;load-&gt;library("pages");
      }
  
      public function display_page()
      {
          $page_slug = $this-&gt;uri-&gt;segment(1);
          $data["joes"] = "Here's joes first variable";
          $this-&gt;pages-&gt;get_page($page_slug);
      }
  }
  </code></pre>
  
  <p>and here's the error message i get when i hit my url like this <code>demo.mydomain.com/joes-test</code></p>
  
  <p><a href="https://i.stack.imgur.com/OrzQy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OrzQy.png" alt="ERROR MESSAGE"></a></p>
  
  <p>and here is how my routes are set up. <code>$route['(:any)'] = 'pages/display_page';</code></p>
  
  <p>My <code>Pages.php</code> library works perfect on the back end but it's a large file.  I've only posted the get_page function below.  If you need to see everything let me know.  But i dont believe the issue has anything to do with the library itself. </p>
  
  <pre><code>public function get_page($slug){
      $objPages = new pages();
      $objPages-&gt;get_object('slug="'.$slug.'"');
      return $objPages;
  }
  </code></pre>
  
  <p>[EDIT] If i place the following inside my homepage controller it works.  But the calling function needs to be inside the library. </p>
  
  <pre><code>$this-&gt;load-&gt;library('pages');
  $the_page = $this-&gt;pages-&gt;get_page("joes-test");
  </code></pre>
  
  <p>I want to call <code>$this-&gt;get_object("joes-test")</code> but this doesn't work. <code>get_object()</code> is an inherited function inside the library.</p>
  
  <p>Now oddly enough. The code i put above will NOT work if i do the exact same thing inside the <code>pages</code> controller</p>
  
  <p>any help leading to a solution would be awesome.  I'm under a time crunch and pay to get some assistance. Thanks in advance.</p>