2011-08-28 3 views
0

기본 템플릿 파일 (main.tpl)이 있고 <body> 태그 사이에 서브 페이지를 포함하고 싶습니다. Smarty - 기본 페이지에 서브 페이지 포함

사용자가 링크 뉴스에 expample 위해 클릭 할 때, 그것을 보여주지 news.php ($ smarty-> 디스플레이 ("news.tpl");) main.tpl

과 결합 -> 1 부 main.tpl + news.tpl + main.tpl의 두 번째 부분

News.tpl에는 텍스트와 PHP 코드가 포함되어 있습니다. 예 :

Hello, <php echo $username ?>. Some random text. 

답변

0

: main.tpl에서

$smarty->assign('module', 'news'); 
$smarty->display('main.tpl'); 

은 모듈 템플릿을 포함한다 :

<body>{include file="$module.tpl"}</body> 

당신은 찾을 수 있습니다 여기에 더 약 {include} 유식 기능 : http://www.smarty.net/docs/en/language.function.include.tpl

+0

고마워요.) – Miso

+0

@Miso 왜 당신이 "News.tpl에 PHP 코드가 들어있을 것입니다" –

0

당신은 $smarty->display("main.tpl")을해야하고 main.tpl에서 news.tpl을 포함한다.

0

템플릿에 PHP 코드가 포함되어 있으면 Smarty가 전혀 필요하지 않습니다. 템플릿 파일은 include입니다. 유식 변수에 PHP 할당 템플릿 이름에서