gpt4 book ai didi

php - Smarty中带有消息 'Missing template name'的“SmartyException”

转载 作者:行者123 更新时间:2023-12-02 11:03:53 26 4
gpt4 key购买 nike

我收到错误消息“SmartyException”,并显示消息“缺少模板名称...”。
我很想在Smarty中使用display()显示不同的页面。我从url中获取值并降低页面质量。
我尝试将单引号连接起来,但实际上并没有用。
任何帮助赞赏。
index.html,Confirm.html,finish.html存在于模板目录中的contact文件夹中。

switch($_GET['param']) {
case 1: confirmation();
break;

case 2: send_email();
break;

case 3: finish();
break;
}


function confirmation(){
echo 'index page';

//$smarty->assign('css', "contact");
//$smarty->display('contact/index.html');
$url = '\'contact/index.html\'';
}

function send_email(){
echo 'confirmation page';

//$smarty->assign('css', "contact");
//$smarty->display('contact/confirm.html');
$url = '\'contact/confirm.html\'';
}

function finish(){
echo 'finish page';

//$smarty->assign('css', "contact");
//$smarty->display('contact/finish.html');
$url = '\'contact/finish.html\'';
}



//
$smarty->assign('css', "contact");
//$smarty->display('contact/index.html');
$smarty->display($url);

最佳答案

这是因为您在每个函数中都将$url设为局部变量。您应该创建全局变量,并在每个函数中返回$url,如以下代码所示:

$url = '';
switch($_GET['param']) {
case 1:
$url = confirmation();
break;

case 2:
$url = send_email();
break;

case 3:
$url = finish();
break;
}


function confirmation(){
echo 'index page';

//$smarty->assign('css', "contact");
//$smarty->display('contact/index.html');
$url = 'contact/index.html';
return $url;
}

function send_email(){
echo 'confirmation page';

//$smarty->assign('css', "contact");
//$smarty->display('contact/confirm.html');
$url = 'contact/confirm.html';
return $url;
}

function finish(){
echo 'finish page';

//$smarty->assign('css', "contact");
//$smarty->display('contact/finish.html');
$url = 'contact/finish.html';
return $url;
}



//
$smarty->assign('css', "contact");
//$smarty->display('contact/index.html');
$smarty->display($url);

顺便说一句,我也从每个函数的 $url中删除了单引号,因为它们似乎根本没有必要。

关于php - Smarty中带有消息 'Missing template name'的“SmartyException”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24987975/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com