In most cases, you will want your module to have view (html) files to be outputted to the user e.q. for a feature inside the admin area with form and inputs or some custom feature that will be used for the clients area.
If you haven’t worked with Codeigniter views, you should check their official documentation to get more familiar.
To create views for your module you must create views folder in /modules/[module_name]
After you create the folder views the path will be:
The views files intended to output HTML but the file names must end with .php, for example [module_name]/views/form.php
Loading View Files In Admin Area
The process of loading views in the admin area is the same regular process Codeigniter uses e.q. in your module controller at the very end of the method add:
Sample Admin View
Find an example below for a view file intended for the admin area.
<?php defined(‘BASEPATH’) or exit(‘No direct script access allowed’); ?>
<?php init_head(); ?>
<?php init_tail(); ?>
Loading View Files in Clients Area
When your module needs to load a view file for the theme area, make sure that your controller extends the ClientsController.
defined(‘BASEPATH’) or exit(‘No direct script access allowed’);
class Sample_module extends ClientsController
public function index()
* Pass data to the view
$this->data([‘sample_data’ => ]);
* Set page title
* The view name
* Render the layout/view
Loading View Files in Other Location
The views in most cases are loaded from the controllers, but if you want to load view file e.q. from helper or custom PHP class or function, you will need to prefix the file with your module name.
Here is a quick example
$CI = &get_instance();
Working With Forms
Click here to read more about working with forms in views.