2014-07-13 2 views
0

PHP에서 이와 같은 것이 가능한지 알고 싶습니다.링크가 바뀌면 다른 로딩을 포함합니다.

나는 인덱스 페이지에 TPL을 할당 할하고 버튼을 클릭하고 인덱스 변화가 제휴 프로그램에 가입 할 때 내가 다른 TPL이 같은

뭔가 assing 할 : 설명에서

if('rendered_page' = signup.php){ 

$t->assign('rendered_page', $t->fetch('signup.tpl')); 

{else} 

$t->assign('rendered_page', $t->fetch('login.tpl')); 

} 

$t->display('index.tpl'); 
+1

'{else}'? '} else {'로 대체 하시겠습니까? –

답변

-1

<?php 
$currentpage = basename($_SERVER['PHP_SELF']); 
?> 

그래서 코드가 될 것이다 : 당신은 내가 당신은 현재 페이지가 무엇인지 확인할 필요가 있다고 생각 제공, 수행 할 수

<?php 
$currentPage = basename($_SERVER['PHP_SELF']); 

if($currentPage == "signup.php"){ 

    $t->assign('rendered_page', $t->fetch('signup.tpl')); 

}else{ 

    $t->assign('rendered_page', $t->fetch('login.tpl')); 

} 
?> 
0

모든 것은 구조와 필요에 따라 다릅니다. (한편, index.tpl

{$rendered_page} 

에서

PHP

<?php 

$currentUrl = $_SERVER['REQUEST_URI']; 

if($currentUrl == 'signup.php') { // notice that there are 2 = signs not one to compare 

$t->assign('rendered_page', $t->fetch('signup.tpl')); 

else { 

$t->assign('rendered_page', $t->fetch('login.tpl')); 

} 

$t->display('index.tpl'); 

에서하지만 당신은 이런 식으로 할 수도 있습니다 :

당신은 예를 들어 이런 식으로 그것을 할 수 있습니다 먼저 가져 오지 않는 단순한 템플릿 표시) :

PHP 인덱스에서

<?php 

$currentUrl = $_SERVER['REQUEST_URI']; 
$t->assign('currentUrl', $currentUrl); 
$t->display('index.tpl'); 

에서 : PHP

<?php 

$currentUrl = $_SERVER['REQUEST_URI']; 

if($currentUrl == 'signup.php') { // notice that there are 2 = signs not one to compare 

$t->display('signup.tpl'); 

else { 

$t->display('login.tpl'); 

} 

마지막 옵션은 직접 스마티 템플릿이를두고있다, 그래서 당신은 이런 식으로 할 수에서

.tpl

{if $currentUrl eq 'signup.php'} 
    {include 'signup.tpl'} 
{else} 
    {include 'login.tpl'} 
{/if} 
관련 문제