Smarty cleverly handles the content page code in iframe. I don't need to talk about it. I should know that iframe is often used to process navigation when I go into the background. if I do this function based on the general idea, it's quite simple, but when I'm not talking nonsense, let's get started.
I should know that iframe is often used to process navigation. it is quite simple to do this function according to the general idea.
However, when I used smarty, I found the problem. for example, an iframeset is divided into: top header, menu on the left, main on the right,
In normal cases, if smarty is used for processing, it is generally like this:
If the three pages are only static pages, they are processed as follows:
Iframe.html code:
The code is as follows:
Suppose that the content pages in iframe must be applied to some special processing, such:
Top.html needs to display the background login username
In menu.html, menus are dynamically obtained.
Main.html needs to read server information
In this way, we will use three background processing pages for the three content pages respectively.
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 the iframe page
Smarty_Output('iframe.html ')
The above processing method can fully meet the requirements
Iframe.html code:
The code is as follows:
Now let's assume that we want to divide the three content pages into roles. different roles and three pages need different effects.
According to the above processing method, we need to process three pages separately, so we naturally have more redundant processing, and the maintenance will be troublesome in the future.
So I thought of the following method, and developed a dedicated processing program iframe. php, simulating the above three pages through conditions.
Directly paste the code:
Iframe. php background code:
The code is as follows:
/* 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:
The code is as follows:
Through this process, I feel much more convenient.
I should know that iframe is often used to process navigation when the Ingress is used in the background. if you follow the general idea to do this function, it is quite simple, but when I use it...