2009-12-10 4 views

답변

2

사용자 세션에 사용 된 테마의 이름을 저장하십시오. 그런 다음 각 컨트롤러 생성자에서 값의 존재를 확인하고 데이터베이스에 테마 이름의 존재 여부를 확인한 다음 뷰에 데이터를 제공합니다.이 데이터는 포함 된 헤더를 통해 차례대로 처리됩니다.

데이터베이스는 다음과 같이 표시됩니다

<?php include header.php ?> 

header.php이 포함됩니다 :

theme_id | theme_name | theme_css 
------------------------------------ 
1  | default | default.css 
2  | fancy  | fancy.css 

귀하의 의견은 모두 같은 것을 포함

<link href="/css/<?=$theme_data->css?>" rel="stylesheet" type="text/css" /> 

그리고 당신의 표준 컨트롤러를 확장하는 기본 컨트롤러는 다음과 같습니다.

<?php 
class Base_Controller extends Controller 
{ 
    protected $theme = 'default'; 
    function __construct() 
    { 
     parent::Controller(); 
     if ($this->session->userdata('theme') 
     { 
      $this->theme = $this->session->userdata('theme'); 
     } 
     $this->view->data['theme_data'] = $this->get_theme_data(); 

    } 

    protected function get_theme_data() 
    { 
     // return data from database using $this->theme 
    } 

}