【问题标题】:How to use frames in smarty如何在 smarty 中使用框架
【发布时间】:2010-09-07 12:25:17
【问题描述】:

这是php文件

<?php
 require_once ('lib/config.inc.php');
require_once ('lib/smarty.php');
require_once ('lib/DataBase.php');

$n="shaz";
$p="pwd";

//Data Retrieving
$db = new DataBaseReader(DB_HOST, DB_NAME, DB_USER, DB_PASS);
try{

    $db->connect();
    $user = $db->login($n,$p);

    if($user=="false")
echo "no login" ;

    else
    { echo $user;
    $_SESSION['sessUser']=$user;   
    }


    }
    catch(Exception $e){
        echo "Exception: " . $e;

    }
    $db->disconnect(); //finally!!!
         $smarty = new MyDir_Smarty();
         $smarty->assign('user_type',$user); 
         $smarty->display('result.html');




     mysql_close();
    ?>

这是 result.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
                    {$user_type}  
<frameset rows="80,*" frameborder="no" border="0" framespacing="0">
  <frame src="topFrame.html" name="topFrame" scrolling="No" noresize="noresize" id="topFrame" title="topFrame" />
  <frame src="mainFrame.html" name="mainFrame" id="mainFrame" title="mainFrame" />
</frameset>
<noframes><body> 
</body>
</noframes></html>

如果我在服务器上运行 html 文件,它工作正常,但是当我尝试使用 smarty 显示它时,我得到一个空白页。我尝试将其保存为 php 但仍然无法正常工作..尝试保存为 .tpl 文件但仍然得到相同的结果。 谁能帮忙。

谢谢

【问题讨论】:

  • 查看 php 错误日志。空页 = php 错误
  • 或开启 PHP 错误报告:error_reporting(E_ALL);
  • 避免使用框架的诱惑。这总是一个坏主意。框架在过去是一个被弃用的想法:未来的 HTML 版本可能不再有框架(尽管 &lt;iframe&gt; s 略有不同)。
  • 我是新手..如果我不使用框架我该怎么办
  • @Pekka 我在哪里添加此行以打开 php 错误报告

标签: php smarty


【解决方案1】:

看起来body标签不见了。

试试这个:

<body>
{$user_type}  
<frameset rows="80,*" frameborder="no" border="0" framespacing="0">
<frame src="topFrame.html" name="topFrame" scrolling="No" noresize="noresize" id="topFrame" title="topFrame" />
<frame src="mainFrame.html" name="mainFrame" id="mainFrame" title="mainFrame" />
</frameset>
<noframes></noframes>
</body>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-27
    • 1970-01-01
    • 2010-09-07
    • 1970-01-01
    • 1970-01-01
    • 2019-10-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多