| 제목 | [팁] 스캐폴드 (Scaffolding) 스킨형식으로 디자인하기 | ||
|---|---|---|---|
| 글쓴이 | ci세상 | 작성시각 | 2009/11/11 00:40:36 |
|
|
|||
|
1. 목적 : 스캐폴드 뷰를 커스트마이즈 할 수 있는 부분을 추가하기 위하여 만들어 보았습니다. 2. 비교 : cakephp에 기본적으로 지원되는 기능을 codeigniter에서도 지원해 주기 위함이 있습니다. 3. 주의 : 기본코어 소스를 일부 만지는 부분이 발생하기 때문에 꼭 필요한 분만 사용해 주시기 바랍니다. 4. 테스트환경 : ci 1.7.2 / apmsetup / 윈도우xp system/libraries/Controller.php (코어수정 : 확장이 안되기 때문에 어쩔 수 없이 만지는 부분입니다.) 108줄
function _ci_scaffolding()
{
if ($this->_ci_scaffolding === FALSE OR $this->_ci_scaff_table === FALSE)
{
show_404('Scaffolding unavailable');
}
$method = ( ! in_array($this->uri->segment(3), array('add', 'insert', 'edit', 'update', 'view', 'delete', 'do_delete'), TRUE)) ? 'view' : $this->uri->segment(3);
require_once(BASEPATH.'scaffolding/Scaffolding'.EXT);
$scaff = new Scaffolding($this->_ci_scaff_table,$this->_ci_scaff_skin);
$scaff->$method();
}
system/application/libraries/MY_Loader.php 파일 추가
<?
/**
* 스캐폴더 스킨으로 구분하기 (2009년 11월 ci세상)
*
*/
class MY_Loader extends CI_Loader {
function scaffolding($table = '', $skin = '')
{
if ($table === FALSE)
{
show_error('You must include the name of the table you would like to access when you initialize scaffolding');
}
$CI =& get_instance();
$CI->_ci_scaffolding = TRUE;
$CI->_ci_scaff_table = $table;
$CI->_ci_scaff_skin = $skin;
}
}
scaffolding/Scaffolding.php
function Scaffolding($db_table,$skin_name)
{
$this->CI =& get_instance();
$this->CI->load->database("", FALSE, TRUE);
$this->CI->load->library('pagination');
// Turn off caching
$this->CI->db->cache_off();
/**
* Set the current table name
* This is done when initializing scaffolding:
* $this->load->scaffolding('table_name')
*
*/
$this->current_table = $db_table;
/**
* Set the path to the "view" files
* We'll manually override the "view" path so that
* the load->view function knows where to look.
*/
$this->CI->load->_ci_view_path = BASEPATH.'scaffolding/'.$skin_name.'/views/';
// Set the base URL
$this->base_url = $this->CI->config->site_url().'/'.$this->CI->uri->segment(1).$this->CI->uri->slash_segment(2, 'both');
$this->base_uri = $this->CI->uri->segment(1).$this->CI->uri->slash_segment(2, 'leading');
// Set a few globals
$data = array(
'image_url' => $this->CI->config->system_url().'scaffolding/'.$skin_name.'/images/',
'base_uri' => $this->base_uri,
'base_url' => $this->base_url,
'title' => $this->current_table
);
$this->CI->load->vars($data);
// Load the language file and create variables
$this->lang = $this->CI->load->scaffold_language('scaffolding', '', TRUE);
$this->CI->load->vars($this->lang);
// Load the helper files we plan to use
$this->CI->load->helper(array('url', 'form'));
log_message('debug', 'Scaffolding Class Initialized');
}
<스킨폴더 위치> system/scaffolding/스킨폴더명 <컨트롤러에서 사용시> $this->load->scaffolding('테이블명','스킨폴더명'); => 위와같이 스킨폴더명을 지정하는것이 하나 더 추가가 됨으로써 codeigniter도 스캔폴더를 개발자가 다양하게 디자인을 해서 사용할 수 있습니다. 파일첨부로 전체소스 올려둡니다. |
|||
| 첨부파일 |
scaffolding_full.zip (401.1 KB) |
||
| 다음글 | [팁] 큐브리드 (CUBRID) 모듈배포 v1 (4) | ||
| 이전글 | 위지윅에디터 ckeditor 사용하기(CodeIgnit... (5) | ||
| 없음 |