Welcome Guest, Not a member yet? Register   Sign In
wrapper method
#4

i think i didnt explain well Sleepy

PHP Code:
class Example extends MY_Controller
{
 
   public function method1()
 
   {
 
        // code example
 
        $this->set_title("method1");
 
        $this->add_script('script');
 
        $this->add_stylesheet('stylesheet');
 
        $this->add_content('view/example', array('args' => 1));
 
        // no call to $this->render() at the end, this should be done automatically 
 
   }

 
   public function method2()
 
   {
 
       // same
 
   }

 
   public function index()
 
   {
 
       // same
 
   }


the render() method actually calls $this->load->view() to add header, body and footer.

PHP Code:
class MY_Controller extends CI_Controller
{
 
   ...
 
   public function wrap()
 
   {
 
       $args func_get_args();
 
       $method array_shift($args);
 
       $this->{$method}(...$args);
 
       $this->render();
 
   }
}

// in config.php
$route[(:any)+/(:any)+(/:any)?] = '$1/wrap/$2$3'

i did this but it can lead to security issues
Lumos...
Reply


Messages In This Thread
wrapper method - by blinkofaneye - 09-25-2018, 11:39 PM
RE: wrapper method - by ignitedcms - 09-26-2018, 03:56 AM
RE: wrapper method - by dave friend - 09-26-2018, 06:08 AM
RE: wrapper method - by blinkofaneye - 09-26-2018, 10:45 PM
RE: wrapper method - by InsiteFX - 09-27-2018, 03:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB