Creating Your Own Content
If you want to add your own custom code to the system, follow this guide. This guide is only if you wish to add pages/content/features using PHP.
Creating your own pages in PHP requires you to use the CodeIgniter framework. It's quite simple to use if you have some programming experience. You can view our test content file here: application/controllers/Test.php
To create a page, first you will want to create a Controller file. This file will be where you main PHP code logic goes. Below is an example controller file. The file must be saved as the same name as the class (with a captial letter). So for example, the class here is called Example, so the controller file must be called Example.php. The file must be placed inside the application/controllers/ folder.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Example extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model("user_model"); if(!$this->user->loggedin) { redirect(site_url("login")); } } public function index() { $this->template->loadContent("example/index.php", array( ) ); } } ?>
The name of the Controller is also used to access the page. Since we named our controller Example, we can now access it using our URL like so: http://www.mysite.com/example/
There are a few more things to look at here too. If you notice inside the index() function, there is this line:
$this->template->loadContent("example/index.php", array( ) );
This line is saying to load the HTML file stored in application/views/example/index.php. If you want to create your own HTML files, you can. Simply create a folder inside the application/views/ folder. Name it whatever you like. For this example, let's call it example. Inside that folder, create your very own PHP file that will be used to display the HTML. Let's create a file called test.php and put some code inside it:
Hello, this is a test! We save it as a .php file so that we can also include PHP code. Like this:
Now, we need to edit our controller file application/controllers/Example.php to use our new HTML file that we just created. So edit the loadContent() function to use it, like so:
$this->template->loadContent("example/test.php", array( ) );
Now when you load the Example page, it will display the content inside application/views/example/test.php.
If you found that confusing, not to worry! There are thousands of guides out there that use the CodeIgniter framework. There is also the CodeIgniter Documentation, which gives a brilliant easy to understand overview of how to use the system. Don't forget to look at our own test file, which gives examples of how you can restrict access to pages (application/controllers/Test.php). You can also contact us via email if you need extra help.
CodeIgniter User Guide: http://www.codeigniter.com/user_guide/