[eluser]esra[/eluser]
I use EXT JS 2.0 and CodeIgniter 1.5.4 in conjunction with the Matchbox extensions (formerly Modular Separation by Zacharias) and the Proposed View library (View library X3 from Coolfactor).
Sample Contact controller extended from a base controller called Application.
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
require(APPPATH.'libraries/application'.EXT);
class Contact extends Application {
public function __construct()
{
parent::__construct();
$this->lang->load('contact', 'en-us');
$this->load->model('contact_model');
}
public function index()
{
$module = $this->lang->line('contact_module');
$page = $this->lang->line('contact_title');
$this->view->set('title', $page);
$this->view->set('module', $module);
$this->view->part('west', 'west');
$this->view->part('north', 'north');
$this->view->part('center2', 'center2');
$this->view->part('center1', 'center1');
$this->view->part('east', 'east');
$this->view->part('south', 'south');
$this->view->load('complex');
}
}
Template: complex.php
Code:
<html>
<head>
<title><?=$title?></title>
<!-- Global Style -->
<link rel="stylesheet" type="text/css" href="<?=javascript_url();?>extjs/resources/css/ext-all.css" />
<!-- End Global Style -->
<!-- Libraries -->
< script type="text/javascript" src="<?=javascript_url();?>extjs/adapter/ext/ext-base.js">
< script type="text/javascript" src="<?=javascript_url();?>extjs/ext-all.js">
<!-- End Libraries -->
<!-- Current Template -->
<link rel="stylesheet" type="text/css" href="<?=template_url();?>complex/css/complex.css" />
< script type="text/javascript" src="<?=template_url();?>complex/js/complex.js">
<!-- End Current Template -->
</head>
<body>
< script type="text/javascript" src="<?=javascript_url();?>common.js">
<?=$west?>
<?=$north?>
<?=$center1?>
<?=$center2?>
<?=$east?>
<?=$south?>
</body>
</html>
The html for the North, West, Center1, Center2, East, and South views can be cut and pasted into separate view files from the Complex layout example. Coolfactor's View library is called in the index method to embed the various views in the template.
common.js is a renamed version of the EXT JS examples.js file. In the template above, I added a space between '<' and 'script' to prevent the EE forum from truncating those lines. The space needs to be removed. The above should work without Matchbox.
javascript_url() and template_url() are two functions in a helper that I use to set the paths to the directories where I store Javascript libraries and the templates/ directory under APPPATH.
In the above, module name and title are strings in the module's language file. Variable replacement is used by the View library to embed the various views and strings in the template.
If you need a copy of the helper and my modified MY_Loader that supports templates/ and blocks/ (partials) directories for use with Matchbox, leave me a PM with an email address. You will also need a copy of the constants.php file that I use in the helper to set application constants and other defines.