Introduction: This is a note: This is a detailed page that enables ecshop templates to reference constants. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 337306 'rolling = 'no'>
It is said that the template class of ecshop is the modified smarty, but I personally feel that the modification is not completely rewritten. It is the same as the template tag on smarty, and has many features.
For example, $ smarty. Const. 'constant 'cannot be used.
In fact, the template engine is not complex in principle. It just replaces some template labels with functions, variables, and syntax structures in PHP.
To add the reference constant function to the ecshop template this time, you only need to add two rows to the make_var () function.Code
1 function make_var ($ Val)
2 {
3 if (strrpos ($ Val, '.') = false)
4 {
5 If (isset ($ this-> _ var [$ Val]) & isset ($ this-> _ patchstack [$ Val])
6 {
7 $ val = $ this-> _ patchstack [$ Val];
8}
9 $ P = '$ this-> _ var [\ ''. $ Val.' \ ']';
10}
11 else
12 {
13 $ T = explode ('.', $ Val );
14 $ _ var_name = array_shift ($ t );
15 if (isset ($ this-> _ var [$ _ var_name]) & isset ($ this-> _ patchstack [$ _ var_name])
16 {
17 $ _ var_name = $ this-> _ patchstack [$ _ var_name];
18}
19 if ($ _ var_name = 'smarty ')
20 {
21 if ($ t [0] = 'const '){
22 return strtoupper ($ t [1]);
23 }
24 $ P = $ this-> _ compile_smarty_ref ($ t );
25}
26 else
27 {
28 $ P = '$ this-> _ var [\ ''. $ _ var_name.' \ ']';
29}
30 foreach ($ T as $ Val)
31 {
32 $ P. = '[\ ''. $ Val.' \ ']';
33}
34}
35
36 return $ P;
37}
Lines 21-23 are newly added, which allows you to reference constants defined in PHP through {$ smarty. Const. Constant} in the template file.
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/337306.html pageno: 9.