Welcome Guest, Not a member yet? Register   Sign In
best way to do this?
#3

[eluser]toopay[/eluser]
use 'pre_controller' and 'post_controller' hooks.

enable hooks in 'application/config'
Code:
$config['enable_hooks'] = TRUE;
then write hook configuration
Code:
$hook = array(
        'pre_controller'   => array(
                                'class'    => 'Bootstrap',
                                'function' => 'before',
                                'filename' => 'Bootstrap.php',
                                'filepath' => 'hooks',
                                'params'   => NULL
                                ),
        'post_controller'  => array(
                                'class'    => 'Bootstrap',
                                'function' => 'after',
                                'filename' => 'Bootstrap.php',
                                'filepath' => 'hooks',
                                'params'   => NULL
                                ),
        );
Now you can do your stuff. Write a new file, called 'Bootstrap.php' under 'application/hooks', then write something like...
Code:
<? defined('BASEPATH') or die('No direct script access allowed.');

class Bootstrap {

protected $_CI;

  public function __construct(){
     $this->_CI =& get_instance();
  }

  public function before(){
     // Do your pre-controller stuff
     // .....
  }

  public function after(){
     // Do your post-controller stuff
     // .....
     $this->_CI->load->vars($data);
     $this->_CI->load->view('template');
  }

}


Messages In This Thread
best way to do this? - by El Forum - 04-10-2011, 03:18 AM
best way to do this? - by El Forum - 04-10-2011, 03:20 AM
best way to do this? - by El Forum - 04-10-2011, 07:34 AM
best way to do this? - by El Forum - 04-10-2011, 07:37 AM
best way to do this? - by El Forum - 04-10-2011, 09:51 AM
best way to do this? - by El Forum - 04-10-2011, 10:18 AM
best way to do this? - by El Forum - 04-11-2011, 09:34 PM
best way to do this? - by El Forum - 04-12-2011, 06:35 AM
best way to do this? - by El Forum - 04-12-2011, 10:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB