레이아웃에서 php문의 function을 사용하고 싶었는데
기존의 다른 레이아웃 스킨에서는 일절 그런 코드를 찾아볼 수가 없었는데
스낙스님의 slow 스킨에서는 function 클래스를 php에서 불러와서 사용하고 있더군요.
{@ // PHP Variables }
<include cond="!$themeConfig" target="_config.php" />
{@
$li = $layout_info;
/// 컬러모드 구분을 위한 쿠키 체크
if($_COOKIE['is_dark_theme']) $li->is_dark_theme = $_COOKIE['is_dark_theme'];
// 컬러 모드
$isDarkMode = $li->is_dark_theme;
// theme 선언
$themeConfig = new ThemeConfig();
$themeConfig->variables = $themeConfig->getVariables($isDarkMode);
// 컬러 모드를 변수로 전달
$themeConfig->variables['dark-mode'] = $isDarkMode;
// 레이아웃 설정을 변수로 전달
if($li->primary_color)
$themeConfig->variables['color-primary'] = $li->primary_color;
if($li->container_width)
$themeConfig->variables['base-container'] = $li->container_width;
if($li->custom_font_family)
$themeConfig->variables['font-family'] = $li->custom_font_family;
if($li->header_darken == 'Y')
$themeConfig->variables['header-darken'] = $li->header_darken;
}
_config.php 파일은 다음과 같습니다.
<?php
class ThemeConfig {
// 변수 시스템
public function getVariables($darkMode) {
$base = array(
'base-container' => '1366px',
'base-padding' => '1.25rem',
'header-darken' => '',
);
return $variables;
}
}
?>
<?php
class themeconfig{
function plus($mid,$category){
return $mid + $category;
}
}
?>
<include target="../lib/function.php" />
{@
$themeconfig = new themeconfig();
$themeconfig->plus = $themeconfig->plus($mid,$category);
}
<div class="swiper-slide">
{var_dump($themeconfig->plus('1','1'))}
</div>
이렇게 하면 되긴 하는데..
foreach를 function 내부에 쓸 수 있는가 했는데 잘 모르겠네요.