Module Views

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:
/modules/[module_name]/views

The views  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:

$this->load->view('form');

Sample Admin View

Daedelix PSA does not have any template engine for the admin view, probably you will want to use the header and sidebar for the admin area and all required Javascript/CSS files, in this case, you can use 2 functions init_head() and init_tail() in your view to achieving this.

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(); ?>
<div id="wrapper">
   <div class="content">
      <div class="row">
         <div class="col-md-12">
            <div class="panel_s">
               <div class="panel-body">
               </div>
            </div>
         </div>
      </div>
   </div>
</div>
<?php init_tail(); ?>
</body>
</html>

Loading View Files in Clients Area

The  area has a slightly different process of loading the files because uses a theme, in this case, you will want your module to get the theme footer and header, including any CSS and Javascript files.

When your module needs to load a view file for the theme area, make sure that your controller extends the ClientsController.

<?php

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
         */
        $this->title('Page Title');

        /**
         * The view name
         */
        $this->view('participate');
        /**
         * Render the layout/view
         */
        $this->layout();
    }
}

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

function module_name_load_customer_form(){
	$CI = &get_instance();
	$CI->load->view('module_name/form');
}

Working With Forms

Click here to read more about working with forms in views.

Did you find this article useful?

  • Introduction to modules

    The modules documentation is valid starting from version 1.2.3.2 Daedelix PSA version 1.2.3.0 comes ...
  • Module Basics

    The modules documentation is valid starting from version 2.3.2 Daedelix PSA modules use the Code...
  • Module File Headers

    Each module in Daedelix PSA consist of init file which contains the general module configuration an...
  • Create Menu Items

    If you are creating your custom modules, probably you will want to create menu items that will be s...
  • Common Module Functions

    register_activation_hook /** * Register module activation hook * @param string $module module s...