0
포함 할 파일을 동적으로 설정하는 방법이 있습니까? 시도 할 때 오류 메시지가 나타납니다 (아래 참조).Smarty 동적 템플릿 포함
/templates/main.tpl
<!DOCTYPE html>
<html>
<head>
<title>My Title</title>
</head>
<body>
{include file='$file'}
</body>
</html>
그리고이 PHP 코드 :
<?php
switch($page){
case "page1":
$file = "/templates/page1.tpl";
break;
case "page2":
$file = "/templates/page2.tpl";
break;
case "page3":
$file = "/templates/page3.tpl";
break;
}
$smarty->assign("file", $file);
$smarty->display("/templates/main.tpl");
스마티 다음 나에게이 오류가 발생합니다 :
예를 들어이 템플릿을'/templates/main.tpl'에 '$ file'템플릿 파일을로드 할 수 없습니다.
해당 위치에서 사용할 템플릿을 동적으로 설정하는 방법이 있습니까?