小弟最近在学习PHP技术,学到Smarty模版的时候遇到这个问题,
index.php文件里使用iframe的时候,iframe页面指向一个tpl文件,
打开之后不是显示页面内容,而是出现下载的框.
这是怎么回事,tpl文件里能不能使用iframe的?
php页面里使用iframe能不能指向tpl的?
还有,我看了一些php的例子,很多的人做PHP项目的时候都选择了混编去做.
PHP类似于JAVA的WVC框架有哪些外面现在主流使用的?
麻烦知道的大哥们告诉下,谢了...
index.php文件里使用iframe的时候,iframe页面指向一个tpl文件,
打开之后不是显示页面内容,而是出现下载的框.
这是怎么回事,tpl文件里能不能使用iframe的?
php页面里使用iframe能不能指向tpl的?
还有,我看了一些php的例子,很多的人做PHP项目的时候都选择了混编去做.
PHP类似于JAVA的WVC框架有哪些外面现在主流使用的?
麻烦知道的大哥们告诉下,谢了...
现在我左边的页面都是用一个tpl文件来显示的,
不可能给它改成html或者php吧,否则smarty标签都解析不了了.
<?php
include '../Smarty/configs/config.php';
include '../conn/conn.php';
include '../Entitys/Urls.php';
$menuArray = array();
$sql="select * from tb_type";
$typeRs = mysql_query($sql);
while($typeResult = mysql_fetch_array($typeRs)){
$typeId = $typeResult["typeId"];
$itemSql="select * from tb_urls where type=".$typeId;
$urlRs = mysql_query($itemSql);
$itemStr=array();
$heights=0;
while($urlResult=mysql_fetch_array($urlRs)){
$urlItem = new UrlsClass($urlResult["id"],$urlResult["shortName"],$urlResult["longName"],
$urlResult["urls"],$urlResult["createTime"],$urlResult["type"],$urlResult["pointNum"]);
$itemStr[$urlResult["id"]] = $urlItem;
$heights = $heights+20;
}
$menuArray["item".$typeId] = array("keys"=>$typeResult["typeName"],"values"=>$itemStr,"heights"=>$heights);
}
$smarty->assign("menuArray",$menuArray);
$smarty->display("../Pages/main.php");;
?>这是我主页访问的页面,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<table>
<tr>
<td>
<iframe id= "frm " name= "frm " src="../Pages/left.tpl"></iframe>
</td>
<td>
</td>
</tr>
</table>
</body>
</html>
这是主页smarty显示的主页,
<table>
{{foreach key=key item=item from=$menuArray}}
<tr>
<td valign="top">
<table cellspacing=0 cellpadding=0 width=158 align=center>
<tr style="CURSOR: hand;">
<td style=" border:1px solid #cccccc; background-color:#7B9AE7;" id=list{{$key}} onclick=chang(menu{{$key}},{{$item.heights}},list{{$key}}); height=25><span>{{$item.keys}}</span> </td>
</tr>
<tr>
<td align="left" valign="middle">
<div id=menu{{$key}} style="DISPLAY: none; background-color:#cccccc; border:1px solid #cccccc; FILTER: alpha(Opacity=0); WIDTH: 158px; HEIGHT: 0px">
<table cellspacing=0 cellpadding=0 width=135 align=left>
<tr>
<td height=25>
{{foreach name=sss key=keys from=$item.values item=items}}
<a href="#">{{$items->shortName}}</a>
{{if $smarty.foreach.sss.iteration!=$item.values|@count}}
<br/>
{{/if}}
{{/foreach}}
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</td>
</tr>
{{/foreach}}</table>
这是我页面左边的页面,
既然我用了smarty来显示左边页面的内容,那就不可能换成别的吧``
还有,就是就算我iframe页面通过了,那index.php页面中设置的那些数据,tpl页面能接收到么?
这个left.tpl 你可以改成静态页面,.html,链接也改了或者是建立一个php文件,例如left.php,在left.php里,include smarty.class.php,用smarty解析left.tpl除非特别设定,否则.tpl是会让你下载的
用smarty解析left.tpl具体该怎么做,
你当前页面不是smarty?就算不是,语法也很像,反正是模板解析这个页面怎么用,iframe 的页面也怎么用就是了呗
你想用这个tpl是必须经过php解析过的,不能就这么用
比如
iframe id= "frm " name= "frm " src="lib/left.php"></iframe>left.php里面去调用smarty才能用模板
我上面给出的三个页面,第一个是index.php,也是最先访问的页面,这个页面访问数据库之后转到第二个页面,也就是main.php,而第二个页面也是显示的主页面,这里面的iframe要显示的是left.tpl内容,也就是上面给出的第三个页面.
你上面的这两句代码应该是写在你说的新建的left.php页面的吧.
可是这两句代码好像没看到解析的内容的啊``
我main.php引用left.php,而left.php引用了下smarty配置文件之后直接显示了main.php```
恕我愚钝,我没看懂是什么意思..
额``现在就是说解析tpl这步该怎么做,
就像我上面说的,我显示的页面都在tpl里的``
现在在left.php解析tpl的内容,该怎么解析额``
<?php
include '../Smarty/configs/config.php';
include '../conn/conn.php';
include '../Entitys/Urls.php';
//
//这里用程序获取left.tpl里需要的变量或数据。
//
$smarty->assign("变量或数据名","变量或数据值");
$smarty->display("left.tpl");//这个地址要正确,相对于left.php的地址?><iframe id= "frm " name= "frm " src="left.php"></iframe>