Without further ado, let’s get to the point
Those who have worked in the backend should all know that iframe is often used to handle navigation. If you follow the general idea to do this function, it is quite simple
But when I use smarty For example, an iframeset is divided into: head top, left menu, right main,
Normally, if you use smarty to handle it, it usually looks like this:
If the three pages are just For static pages, the
iframe.html code is processed as follows:
Copy the code The code is as follows:
Assume that the content pages in the iframe are Some special processing needs to be applied, such as:
top.html needs to display the background login user name
The menu in menu.html is dynamically obtained
Main.html needs to read the server information
like this If so, we will use 3 background processing pages for 3 content pages respectively
Copy code The code is as follows:
// 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');
//Display iframe page
smarty_Output('iframe.html')
The above processing method can fully meet the requirements
iframe.html code:
Copy code The code is as follows:
Now we assume that we now need to process these three content pages separately. Different roles, the three pages need to display different effects.
According to the above processing method, we need to process the three pages separately. Processing, so naturally there will be more redundant processing, and future maintenance will be troublesome
So I thought of the following method, independently created a special processing program iframe.php, and simulated the above three through conditions The code is posted directly on the page
:
iframe.php Backend code:
Copy code The code is as follows:
/*Put shared processing code here*/
switch($src)
{
case "top":
/*Put processing code here*/
smarty_Output('top. html');
break;
case "menu":
/*Put processing code here*/
smarty_Output('menu.html');
break;
case "main":
/*Put processing code here*/
smarty_Output('main.html');
break;
default:
break;
}
iframe.html:
Copy code The code is as follows:
By doing this, I feel much more convenient
http://www.bkjia.com/PHPjc/325060.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325060.htmlTechArticle Without further ado, those who have worked in the backend should know that iframe is often used to handle navigation. , if you follow the general idea to do this function, it is quite simple. But when I use...