Sumber asli : http://codeigniter.com/forums/viewthread/130213/ I'm using Ocular on a new project, and it's really a huge timesaver. One thing that I found useful is to have two default templates, one for full requests and one for ajax requests. In application/config/constants.php I appended this snippet, per someone else's suggestion elsewhere in the forums: /* And in config/ocular.php I added a second default_template value (@ line 102) like this: $config['OCU_default_template'] = "application"; Then in libraries/Ocular.php in Ocular::render() (lines 111-112 in v1.0.1) I made a small change to the default template: // controller template doesn't exist, so use the application default Just thought this might be useful for someone.
|--------------------------------------------------------------------------
| detect Ajax request
|--------------------------------------------------------------------------
|
*/
define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
$config['OCU_default_ajax_template'] = "blank";
$template = $this->ci->config->item('OCU_template_dir') . "/" . $this->ci->config->item(IS_AJAX ? 'OCU_default_ajax_template' : 'OCU_default_template');
0 komentar:
Posting Komentar