상수 커스텀
본문
root에 sub라는 폴더를 만들었습니다. 폴더 안에는 이름이 다른 여러개의 폴더들이 있습니다.
이 폴더들을 테마 상수(G5_THEME_PATH)처럼 자동으로 가져오고 싶습니다.
테마 같은 경우는 common.php 파일 안에
// 테마경로
if(defined('_THEME_PREVIEW_') && _THEME_PREVIEW_ === true)
$config['cf_theme'] = isset($_GET['theme']) ? trim($_GET['theme']) : '';
if(isset($config['cf_theme']) && trim($config['cf_theme'])) {
$theme_path = G5_PATH.'/'.G5_THEME_DIR.'/'.$config['cf_theme'];
if(is_dir($theme_path)) {
define('G5_THEME_PATH', $theme_path);
define('G5_THEME_URL', G5_URL.'/'.G5_THEME_DIR.'/'.$config['cf_theme']);
define('G5_THEME_MOBILE_PATH', $theme_path.'/'.G5_MOBILE_DIR);
define('G5_THEME_LIB_PATH', $theme_path.'/'.G5_LIB_DIR);
define('G5_THEME_CSS_URL', G5_THEME_URL.'/'.G5_CSS_DIR);
define('G5_THEME_IMG_URL', G5_THEME_URL.'/'.G5_IMG_DIR);
define('G5_THEME_JS_URL', G5_THEME_URL.'/'.G5_JS_DIR);
}
unset($theme_path);
}
여기서 볼드체로 강조한 부분이 현재 테마의 폴더를 가리키는 것 같은데
$config 라는 함수는 get_config라는 함수더군요. 이 함수는
function get_config($is_cache=false){
global $g5;
static $cache = array();
$cache = run_replace('get_config_cache', $cache, $is_cache);
if( $is_cache && !empty($cache) ){
return $cache;
}
$sql = " select * from {$g5['config_table']} ";
$cache = run_replace('get_config', sql_fetch($sql));
return $cache;
}
이렇게 생겼는데 봐도 이해가 잘 안가네요. 일단 $cache 부분을 보면 데이터베이스에서 뭘 가져오는 것 같은데 말이죠...