템플릿 내 include 시 변수 사용
CMS/프레임워크 | Rhymix 1.9 |
---|---|
개발 언어 | PHP 7.0 |
templates/ 폴더에 {$mid}.html ($mid 변수는 Context::get('mid')와 동일한 값을 반환) 이라는 파일이 있다면
해당 파일을 include 하여 특정 페이지의 템플릿을 출력할 생각이었습니다.
{@
$mid = Context::get('mid');
$template_exists = file_exists(_XE_PATH_ . '/layouts/레이아웃명마스킹/templates/' . $mid . '.html');
}
<include target="templates/{$mid}.html" cond="$template_exists" />
이에, 위와 같은 코드로 시도해 보았으나...
돌아오는 화면은 Template not found: layouts/레이아웃명마스킹/templates{$mid}.html 이네요.
목록을 추려서 슥삭슥삭 각자 조건문 넣어 include 해도 되지만...
그러기에는 템플릿을 추가할 때 마다 목록을 추가해야 할테니, 효용성이 떨어지구요.
방법이 없을까요?
댓글 3
$template_exists = file_exists(_XE_PATH_ . '/layouts/레이아웃명마스킹/templates/' . $mid . '.html');
아래쪽에..
$oTemplate = TemplateHandler::getInstance();
$output = $oTemplate->compile(_XE_PATH_ . '/layouts/레이아웃명마스킹/templates/', $mid . '.html'); 으로 해보세요.
도움 주셔서 감사합니다..^^
혹시 파일 공유가능하시면 제가 해볼게요