Welcome Guest, Not a member yet? Register   Sign In
several controller
#2

(This post was last modified: 07-12-2019, 03:39 AM by InsiteFX.)

Create a MY_Controller

Comments on how to use in the header section of the class.

PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

/**
 * Class Base
 * 
 * File must be saved as MY_Controller.php in
 * ./application/core/MY_Controller.php
 * 
 * Place all your code that is used in all controllers
 * in this controller and then extend all controllers with Base
 * 
 * class Your_Controller extends Base
 * 
 */
class Base extends CI_Controller
{
 
   /**
     * Class properties go here.
     * -------------------------------------------------------------------
     * public, private, protected, static and const.
     */


 
   // -------------------------------------------------------------------

 
   /**
     * __construct ()
     * -------------------------------------------------------------------
     *
     * Class    Constructor
     *
     * NOTE: Not needed if not setting values or extending a Class.
     */
 
   public function __construct()
 
   {
 
       parent::__construct();

 
       log_message('debug'"Base Controller Class Initialized");
 
   }

 
   /**
     * index ()
     * -------------------------------------------------------------------
     *
     */
 
   public function index()
 
   {

 
   }

 
   // -------------------------------------------------------------------

  // End of Base Controller Class.

/**
 * Class Backend
 */
class Backend extends Base
{
 
   /**
     * Class properties go here.
     * -------------------------------------------------------------------
     * public, private, protected, static and const.
     */


 
   // -------------------------------------------------------------------

 
   /**
     * __construct ()
     * -------------------------------------------------------------------
     *
     * Class    Constructor
     *
     * NOTE: Not needed if not setting values or extending a Class.
     */
 
   public function __construct()
 
   {
 
       parent::__construct();

 
       log_message('debug'"Backend Controller Class Initialized");
 
   }

 
   /**
     * index ()
     * -------------------------------------------------------------------
     *
     */
 
   public function index()
 
   {

 
   }

 
   // -------------------------------------------------------------------

  // End of Backend Controller Class.

/**
 * Class Frontend
 */
class Frontend extends Base
{
 
   /**
     * Class properties go here.
     * -------------------------------------------------------------------
     * public, private, protected, static and const.
     */


 
   // -------------------------------------------------------------------

 
   /**
     * __construct ()
     * -------------------------------------------------------------------
     *
     * Class    Constructor
     *
     * NOTE: Not needed if not setting values or extending a Class.
     */
 
   public function __construct()
 
   {
 
       parent::__construct();

 
       log_message('debug'"Frontend Controller Class Initialized");
 
   }

 
   /**
     * index ()
     * -------------------------------------------------------------------
     *
     */
 
   public function index()
 
   {

 
   }

 
   // -------------------------------------------------------------------

  // End of Frontend Controller Class.

// End of MY_Controller Controller Class.


/**
 * -----------------------------------------------------------------------
 * Filename: MY_Controller.php
 * Location: ./application/core/MY_Controller.php
 * -----------------------------------------------------------------------
 */ 

Make sure that you extend all your controllers from Base

Or use can extend the controller using Frontend or Backend
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
several controller - by keiralittle - 07-12-2019, 02:15 AM
RE: several controller - by InsiteFX - 07-12-2019, 03:37 AM
RE: several controller - by vincent78 - 07-12-2019, 03:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB