Without further ado, get down to business As you know, iframe is often used to handle navigation. If you follow the 1-like train of thought to do this function, it is quite simple However, when I use smarty, I find the problem. For example, 1 iframeset is divided into: head top, left menu, right main, Normally, if smarty is used to handle, 1 is like this: If the three pages are just static pages, the following is done iframe. html code:
<frame src="top.html" name="topFrame" id="topFrame" scrolling="no">
<frameset cols="180,*" name="btFrame" id="btFrame" frameborder="NO" border="0" framespacing="0">
<frame src="menu.html" id="leftbar" noresize name="menu" scrolling="yes">
<frame src="main.html" id="rightbar" noresize name="main" scrolling="yes">
</frameset>
Suppose that the content pages in iframe are applied to 1 special processing, such as: top.html needs to display the background login username menu in menu. html is all dynamic fetch main.html needs to read the server’s information In this case, we would have three background pages for each of the three content pages
//top.php:
$smarty->assign('user', $names );
smarty_Output('top.php')
//menu.php:
$arr=array();
$arr=GetMenu();
$smarty->assign('menu', $arr);
smarty_Output('menu.php');
//main.php
$smarty->assign('serverInfo', $serverInfoArr);
smarty_Output('main.php');
// According to iframe page
smarty_Output('iframe.html')
The above processing method, can completely meet the requirements iframe. html code:
<frame src="top.php" name="topFrame" id="topFrame" scrolling="no">
<frameset cols="180,*" name="btFrame" id="btFrame" frameborder="NO" border="0" framespacing="0">
<frame src="menu.php" id="leftbar" noresize name="menu" scrolling="yes">
<frame src="main.php" id="rightbar" noresize name="main" scrolling="yes">
</frameset>
Now let’s assume that we’re going to split the three content pages into roles, and for different roles, the three pages need to display different effects According to the above processing method, we need to deal with the three pages separately, so it is natural to have more redundant processing, and later maintenance is also troublesome So I came up with the following method, which is to create a separate specialized processor, iframe.php, and simulate the above three pages with conditions Directly pasted the code: iframe.php background code:
/* Put the Shared processing code here */
switch($src)
{
case "top":
/* Put the processing code here */
smarty_Output('top.html');
break;
case "menu":
/* Put the processing code here */
smarty_Output('menu.html');
break;
case "main":
/* Put the processing code here */
smarty_Output('main.html');
break;
default:
break;
}
iframe.html:
<frame src="iframe.php?src=top" name="topFrame" id="topFrame" scrolling="no">
<frameset cols="180,*" name="btFrame" id="btFrame" frameborder="NO" border="0" framespacing="0">
<frame src="iframe.php?src=menu" id="leftbar" noresize name="menu" scrolling="yes">
<frame src="iframe.php?src=main" id="rightbar" noresize name="main" scrolling="yes">
</frameset>
By doing this, I feel much more comfortable