Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can autoload your library by changing the <code>application/config/autoload.php</code> file. </p> <p>Find :</p> <pre><code>$autoload['libraries'] = array(); </code></pre> <p>Replace by :</p> <pre><code>$autoload['libraries'] = array('calendar'); </code></pre> <p>To load the same calendar on all your pages, I suggest to build a parent controller in the <code>application/core</code> folder.</p> <pre><code>abstract class BaseController extends CI_Controller { protected $data; public function __construct() { parent::__construct(); $this-&gt;data = array(); $calendarData = array( 3 =&gt; 'Polska - Anglia' ); $this-&gt;data['calendar'] = $this-&gt;calendar-&gt;generate('', '', $calendarData); } } </code></pre> <p>You can then extend that <code>BaseController</code> class on all your controllers.</p> <pre><code>class Calendar extends BaseController { function index() { $this-&gt;load-&gt;view('main/calendar', $this-&gt;data); } } </code></pre> <p>Be sure to always use <code>$this-&gt;data</code> to build on the protected member of your class.</p> <p>Lastly, your <code>BaseController</code> will not be autoloaded, you probably don't want to include it everywhere. I suggest you to add the following method at the end of your autoload or config file.</p> <pre><code>/** * Extra autoload function. Loads core classes automatically. * @param type $class The class to load. */ function __autoload($class) { if (strpos($class, 'CI_') !== 0) { if (file_exists($file = APPPATH . 'core/' . $class . EXT)) { include $file; } } } </code></pre> <p>This will allow you to autoload any classes you have in your <code>application/core</code> folder. This solution might seems complex, but once it's setup. You can add functionality to your <code>BaseController</code> that is applicable for all pages, for example, header and footer stuff. </p> <p>Hope this helps!</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