Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Smarty模板的动态页面布局_Javascript_Css_Templates_Layout_Smarty - Fatal编程技术网

Javascript 使用Smarty模板的动态页面布局

Javascript 使用Smarty模板的动态页面布局,javascript,css,templates,layout,smarty,Javascript,Css,Templates,Layout,Smarty,我是php专业的学生,也是smarty的新手,我知道smarty的语法 在某种程度上,我可以用它来满足基本的需要 计划一个社交网络项目,因为这将是一个相当复杂的过程 复杂的项目我不清楚以下内容 开始编码前的问题: 问题1: 如何为web的不同部分使用不同的布局 应用比如说facebook.com。它的索引页使用一种布局,登录页使用另一种布局,配置文件页使用另一种布局。如何使用smarty模板执行此操作?如何重用模板,将它们分开并使用它们 问题2: 如何基于显示smarty模板上的动态错误消息

我是php专业的学生,也是smarty的新手,我知道smarty的语法 在某种程度上,我可以用它来满足基本的需要 计划一个社交网络项目,因为这将是一个相当复杂的过程 复杂的项目我不清楚以下内容 开始编码前的问题:


问题1: 如何为web的不同部分使用不同的布局 应用比如说facebook.com。它的索引页使用一种布局,登录页使用另一种布局,配置文件页使用另一种布局。如何使用smarty模板执行此操作?如何重用模板,将它们分开并使用它们


问题2: 如何基于显示smarty模板上的动态错误消息 各种编程决策。例如,我们再来看看facebook.com。什么时候 如果您访问facebook.com时禁用了javascript,它会显示一条消息,要求启用 javascript。当您在未登录的情况下访问某人的个人资料时,它会在顶部显示不同的标题和注册栏。当您提供了错误的登录凭据时,它会在同一模板中显示错误消息。当facebook.com需要发布消息时 对它的用户来说,当我们登录我们的主页时,它会显示出来吗?怎么 和smarty一起做这些事


问题3:如何处理不同模板的css样式。怎么 要将javascript与不同的模板一起使用


这些场景听起来可能很普通,但对我来说 信息将是金子。我非常感谢你们中的任何人在看到这一点时给予的任何帮助。如果你能用一些好的示例代码来解释这些东西,这将是对我的巨大支持

[详细解释将不胜感激]


谢谢

您知道smarty是一个模板引擎

关于你的问题1:

您可以通过调用函数display()来决定显示哪个模板

例如:

$smarty->display("header1.tpl");
          $smarty->display("header1.2pl");
      etc..
$smarty->assign("type",$type);
或者,您可以根据传递给tpl的条件包括适当的tpl文件。 例如:

$smarty->display("header1.tpl");
          $smarty->display("header1.2pl");
      etc..
$smarty->assign("type",$type);
然后在tpl中,您可以包括适当的tpl文件,如下所示

{if $type=='condition1'}
  {include file="file1.tpl"}
{elseif $type=='condition2'}
{include file="file2.tpl"}
{/if}
$smarty->assign("error",$errroMessage);
关于你的问题2: 您可以将错误发送到tpl并按如下方式显示

{if $type=='condition1'}
  {include file="file1.tpl"}
{elseif $type=='condition2'}
{include file="file2.tpl"}
{/if}
$smarty->assign("error",$errroMessage);
然后在第三方物流

enter code here

{$error}

正如您所知,smarty是一个模板引擎

关于你的问题1:

您可以通过调用函数display()来决定显示哪个模板

例如:

$smarty->display("header1.tpl");
          $smarty->display("header1.2pl");
      etc..
$smarty->assign("type",$type);
或者,您可以根据传递给tpl的条件包括适当的tpl文件。 例如:

$smarty->display("header1.tpl");
          $smarty->display("header1.2pl");
      etc..
$smarty->assign("type",$type);
然后在tpl中,您可以包括适当的tpl文件,如下所示

{if $type=='condition1'}
  {include file="file1.tpl"}
{elseif $type=='condition2'}
{include file="file2.tpl"}
{/if}
$smarty->assign("error",$errroMessage);
关于你的问题2: 您可以将错误发送到tpl并按如下方式显示

{if $type=='condition1'}
  {include file="file1.tpl"}
{elseif $type=='condition2'}
{include file="file2.tpl"}
{/if}
$smarty->assign("error",$errroMessage);
然后在第三方物流

enter code here

{$error}