Welcome Guest, Not a member yet? Register   Sign In
Difficulty understanding how to code up a webpage
#7

[eluser]esra[/eluser]
Try using Controller rather than CI_Controller for CI 1.53 or 1.54. CI normally appends CI_ to class names at several points in the code, but this does not seem to be working seemlessly in the two most recent versions, especially if your using something like the modular separation contribution.

Try this:

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

class Application extends Controller {

    function Application()
    {
        parent::Controller();
        var_dump($this);
    }

}
?>

Then using something like Coolfactor's proposed View library, you could use something like this for subclassed controllers.

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

require(APPPATH.'libraries/application'.EXT);

class I18n extends Application {

    function I18n()
    {
        parent::Application();
        $this->lang->load('i18n', 'en_us');    
    }
    
    function index()
    {
        $component = $this->lang->line('i18n_component');
        $page = $this->lang->line('i18n_title');
        
        $this->view->set('title', $page);
        $this->view->set('component', $component);
        $this->view->part('tree', 'tree');
        $this->view->part('navigation', 'navigation');
        $this->view->part('tabpanel', 'tabpanel');
        $this->view->part('content', $component);
        $this->view->part('properties', 'properties');
        $this->view->part('output', 'output');
        $this->view->load('complex');
    }
}
?>

The part code loads view fragments. It's possible to move some of these to the constructor of the base cass if you want them to always appear in your template (complex is the template or master view in this case). Or you could conditionally load view fragments by creating methods in the base controller to load different sets of view fragments (parts).


Messages In This Thread
Difficulty understanding how to code up a webpage - by El Forum - 08-08-2007, 10:23 AM
Difficulty understanding how to code up a webpage - by El Forum - 08-08-2007, 10:50 AM
Difficulty understanding how to code up a webpage - by El Forum - 08-08-2007, 12:52 PM
Difficulty understanding how to code up a webpage - by El Forum - 08-09-2007, 04:36 AM
Difficulty understanding how to code up a webpage - by El Forum - 08-09-2007, 09:04 AM
Difficulty understanding how to code up a webpage - by El Forum - 08-11-2007, 12:59 PM
Difficulty understanding how to code up a webpage - by El Forum - 08-11-2007, 07:07 PM
Difficulty understanding how to code up a webpage - by El Forum - 08-12-2007, 02:23 AM
Difficulty understanding how to code up a webpage - by El Forum - 08-12-2007, 02:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB