Note that there are some explanatory texts on larger screens.

plurals
  1. POLoading a Library in CI
    primarykey
    data
    text
    <p>I'm trying to load a library with the name Single_column. I create this library and I set it into the libraries folder. I have to mention at this point that I;m using the code Igniter framework. The Sinle_column class contain the following code:</p> <pre><code> &lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Single_column { public function render( $id ) { $CI =&amp; get_instance(); // DB calls // search for uri in db $CI-&gt;load-&gt;model('m_single_column'); $image = $CI-&gt;m_single_column-&gt;getImageURI( $id ); $text = $CI-&gt;m_single_column-&gt;getText( $id ); // ==== HEADER // eventually, this will be loaded from the db $header_data['title'] = "Single Column Demo"; $header_data['css'][] = "single_column"; $CI-&gt;load-&gt;view('v_header', $header_data); // ==== CONTENT $content_data['content'] = '&lt;div class="content-block"&gt;'; $content_data['content'] .= '&lt;div class="image"&gt;'; $content_data['content'] .= '&lt;img src="' . base_url() . $image . '" width="200" height="133" alt="my tractor"/&gt;'; $content_data['content'] .= '&lt;/div&gt;'; $content_data['content'] .= $text; $content_data['content'] .= '&lt;/div&gt;&lt;!-- end content-block--&gt;'; $CI-&gt;load-&gt;view('v_content', $content_data); // ==== FOOTER $CI-&gt;load-&gt;view('v_footer'); } } ?&gt; </code></pre> <p>Now into the controller folder I have a class with the name: </p> <pre><code> &lt;?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Master extends CI_Controller { function __construct() { parent::__construct(); } public function _remap($method) { // remap overrides function calls // search for uri in db $this-&gt;load-&gt;model('m_master'); $uri_id = $this-&gt;m_master-&gt;findURI(uri_string()); $page; if ($uri_id != false) { $this-&gt;{$page-&gt;controller}-&gt;render( $page-&gt;id ); } else { show_404(uri_string()); } } } ?&gt; </code></pre> <p>The aforementioned code is from a tutorial and my problem is at the following line:</p> <pre><code> $this-&gt;{$page-&gt;controller}-&gt;render( $page-&gt;id ); </code></pre> <p>The displayed error is the following one:</p> <pre><code> Fatal error: Cannot access empty property in C:\xampp\htdocs\PhpProject1\application\controllers\master.php on line 24 </code></pre> <p>Actually I realized that it can't recognize the method 'render'. So, I tried the following lines of code into the if statement</p> <pre><code> $library= Single_column::$uri_id['id'];; $this-&gt;load-&gt;library($library); </code></pre> <p>But I received the following error: Fatal error: Class 'Single_column' not found in C:\xampp\htdocs\PhpProject1\application\controllers\master.php on line 22</p> <p>Moreover, the $uri_id returns an sql object. ButI want to pass only the id attribute of the object.</p> <p>Question: How Can I call a library? And how can I pass a value into a method of a class(render method)? Why the aforementioned lines that didn't work?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload