Level e member's product commend list
Public function product_comm ($ size = 5 ){
$ Pre = $ size <> 5 &&! Empty ($ _ request ['lb'])? "And prolb like '%". $ _ request ['lb']. "% '":"";
$ This-> where = "judge_flag = 0 and pubname = '". $ _ request ['user']. "' $ pre ";
$ SQL = "select id, pingpai, img, huohao from user_proinfo where". $ this-> where.
"Order by pubtime desc ";
$ Res = $ this-> selectrs-> selectlimit ($ SQL, $ size, ($ this-> page-1) * $ size );
$ This-> navipage_cm ("'User _ proinfo '", $ size, $ this-> where );
Return $ res;
}
// Embed in all must be used cat page function
Private function navipage_cm ($ table, $ size, $ where ){
$ Count = $ this-> selectrs-> getone ("select count (*) from $ table where $ where ");
$ Pages = @ ceil ($ count/$ size );
For ($ I = 0; $ I <= $ pages; $ I ++) $ arr [] = $ I;
$ Navi_cm = array ("option" => $ arr,
"Page" => $ this-> page,
"Pages" => $ pages,
"Count" => $ count, string 7
"Size" => $ size,
"Param" => $ this-> param
);
$ This-> tpl-> assign ("navi_cm", $ navi_cm );
}
Smarty code
<Table width = "100%" border = "0" cellpadding = "0" cellspacing = "0">
<Form name = "jump" method = "post" action = "">
<Tr>
<Td height = "28" align = "center" valign = "bottom"> Current page <! -- {$ Navi_cm.page} -->/<! -- {$ Navi_cm.pages} -->
<! -- {If $ navi_cm.pages gt 1 & $ navi_cm.page ne 1} -->
<A href = "? <! -- {$ Navi_cm.param} --> & page = 1 "> [Homepage] </a>
<! -- {Else} -->
[Homepage]
<! -- {/If} -->
<! -- {If $ navi_cm.pages gt 1 & $ navi_cm.page ne 1} -->
<A href = "? <! -- {$ Navi_cm.param} --> & page = <! -- {$ Navi_cm.page-1} --> "> [previous page] </a>
<! -- {Else} -->
[Previous page]
<! -- {/If} -->
<! -- {If $ navi_cm.pages gt 1 & $ navi_cm.page ne $ navi_cm.pages} -->
<A href = "? <! -- {$ Navi_cm.param} --> & page = <! -- {$ Navi_cm.page + 1} --> "> [next page] </a>
<! -- {Else} -->
[Next Page]
<! -- {/If} -->
<! -- {If $ navi_cm.pages gt 1 & $ navi_cm.page ne $ navi_cm.pages} -->
<A href = "? <! -- {$ Navi_cm.param} --> & page = <! -- {$ Navi_cm.pages} --> "> [last page] </a>
<! -- {Else} -->
[Last page]
<! -- {/If} -->
To string 6
<Select name = "changepage" onchange = "re_jump ('<! -- {$ Navi_cm.param} --> ') ">
<! -- {Html_options options = $ navi_cm.option selected = $ navi_cm.page} -->
</Select>
</Td>
</Tr>
</Form>
</Table>
Smarty template analysis
Basic syntax
All smarty labels are added with delimiters. in smarty, all contents other than delimiters are static. When smarty encounters a template tag, it will try to explain them and then output them in an appropriate way.
By default, they are {and}, but they are customizable. The custom method is:
$ Smarty-> left_delimiter = '<! --{';
$ Smarty-> right_delimiter = '} --> ';
1. Notes
Template comments are surrounded by "*", for example, {* this is a comment *}
The smarty annotation will not be output. It is an internal annotation of the template.
2. Variables
The template variable starts with $ and can contain numbers, letters, and underscores.
The config_file variable is an exception and must be referenced using the # variable name # method.
3. Functions
The smarty tag outputs a variable or calls a function.
Functions and their attributes in the delimiters will be processed and output. For example:
{Funcname attr1 = "val" attr2 = "val "}.
Funcname indicates the function name, such as include, attr1, attr2 indicates the attribute name, and val indicates the value corresponding to the attribute.
Both built-in and custom functions have the same syntax in the template.
Built-in functions will work within smarty, such as {if}, {section}, and {strip}. They cannot be modified.