Understanding the phpbb3 style system
phpbb3 is the Smarty template engine, and the friends who have used XOOPS must be unfamiliar to this East, and the XOOPS style system also uses the Smarty template engine.
what is Smarty template engine for friends who do not understand Smarty? (since we are only discussing the style of phpbb3, so there is no detailed description here, and a friend who wants to study this can visit the Chinese handbook of Smarty to know in detail. Here we just have a preliminary understanding of the principles of the phpbb3 style system, which can easily distinguish the code from the template files in the future.
simply, the Smarty template engine compiles various functions and variables in the PHP program into a template variable, and a small variable represents the function expressed in a large heap of PHP code. In the template, only the short variables are added to the position you want, and the function of the code can be implemented. This allows programmers and stylistic designers to work independently without the need of programmers to learn HTML and other knowledge in order to design style, and stylistic designers do not need to learn PHP knowledge for design style. We compare the many functions and variables in the PHP program as candy, and the Smarty template engine is like a sugar paper. We don't need to know how those sweets are made. We just see the sugar paper and what kind of candy is wrapped in the sugar paper; the staff of the supermarket can be easily rooted. According to the candy packaging, put the candy in the place you want, without caring about its production process. A programmer is a candy producer, and a supermarket employee is a style designer.
see here, I think you probably know what the Smarty template engine is, and I believe you have already realized that the style of doing phpbb3 is like a building block. 0
below is the basic knowledge of some Smarty template engines. You can get a better understanding of it. (though I don't ask, but I think it's necessary, not write)
some concepts using Smarty. In the like template engine, we often see the concept of the region, the so-called blocks will probably grow to this way:
.Lt;! START: Block name --.gt;
.Lt; END: Block name. Control their display status. Although the template looks much more concise, as long as a template with different display modes is changed, the PHP program needs to be changed again.
in Smarty, all variables are dominant, and all rendering logic controls the template itself. Because Smarty has its own template language, no matter whether the block is to be displayed or repeated, it is presented with the Smarty's template syntax (if, foreach, section) with the variable content. So it feels like a template is a bit complicated, but the advantage is that as long as the planning is right, PHP programs need not be changed.
from the above description, we can know that the use of Smarty requires a principle: a clear separation between the application logic of the program and the web presentation logic. That is to say, there should not be too many HTML codes in the PHP program. As long as the variables are determined in the program, the template itself decides how to render these variables.