[转] Smarty instance tutorial --- template design part

xiaoxiao2021-03-06  60

Smarty instance tutorial

--- Template Design Some Keywords: Smarty, PHP Template Engine One, what is Smarty? Smarty is a template PHP template engine written by PHP, which provides the separation of logic and external content, simple speaking, purpose is To use the PHP programmer to separate, the logical content of the programmer to change the program is not affected by the artist page design, the art re-modify the page does not affect the program logic of the program, which is displayed in multiplayers. especially important. Second, Smarty Advantages: 1. Speed: Programs Writing with Smarty can improve the maximum speed, which is relative to other template engine technology. 2. Compiling: The program written by Smarty is compiled into a non-template-based PHP file. This file uses PHP and HTML mixed mode. When the next access template, the web request is directly converted to this file, No longer performing template recompilation (in the case where the source program is not changed) 3. Cache technology: Smarty selected a cache technology, which can cache the user's final HTML file into a static HTML page, When Smarty's Cache property is True, convert the user's web request directly to this static HTML file during the Cachetime period set by Smarty, which is equivalent to calling a static HTML file. 4. Plugin Technology: Smarty can customize the plugin. The plugin is actually some custom functions. 5. IF / ELSEIF / ELSE / ENDIF can be used in the template. The template file is used to use the judgment statement that can be easily reundrained to the template. Third, not suitable for using Smarty: 1. Real-time update content. For example, shares show that it needs to be updated often, this type of program uses Smarty to slow down the template processing speed. 2. Small project. Small projects use Smarty to lose the rapid advantages of PHP development because of the simple projects and programmers and one person. Fourth, install the Smarty class: Install the environment: PHP version 4.06 or later. Installing the Smarty method is very simple, from http: //smarty.php.net/do_download.p ... 獿 IBS all files to copy to the comm directory, complete the basic installation. Other advanced installation methods Please see the manual. Five, smarty Use in the template: This section takes several instances to talk about Smarty. The Smarty Template is usually used. TPL logo, some people write the extensions directly into .html for the convenience of the United States, and it is possible. This article uses a Smarty standard write: in .tpl to represent a smarty template. PHP code: ----------------------------------------------- -------------------------------- Example 1: First look at a simple example.

============================================================================================================================================================================================================= === Index.tpl ================================================= ========= {* Display is the use of the smarty variable identifier * contains text to comment content *} {include file = "header.tpl"} {* page *} Hello, my name {$ name}, welcome everyone to read my smarty learning materials. {include file = "foot.tpl"} The example on the top of the page *} is a TPL template, where: 1. {**} is a comment for the template page, which is not paid when SMARTY parsed the template Output, only template designers are annotated. 2. {include file = "xxx.tpl"} Use this sentence to include a template file to the current page, the example in the example will contain the Head.tpl and FOOT.TPL of the public thing in the website, you can think, Use this sentence to copy all of the contents in XXX.TPL at the current statement. Of course, you can also use this sentence, you can copy the contents of XXX.TPL to the current statement. 3. {$ Name}: Template variable, core composition in Smarty, using the left boundary {with the right boundary} in smarty, is given in the form of a PHP variable, where $ smarty-> assign will be used in the Smarty program ("Name", "Li Xiaojun"); replacing the $ Name in the template into three words of "Li Xiaojun".

The entire example source program is as follows: ================================================ ================= Master Smarty Tutorial </ Title> </ head> <body> ========= ====================== foot.tpl ================================================================================================================================================================================================================================== ====== <hr> <center> Copyright (c) by Master Email: teacherli@163.com </ center> <hr> </ body> </ html> ===== ========================================================= Index. TPL ================================================== ==== {* Display is the use of the smarty variable identifier * {include file = "Header.tpl"} {* page *} Hello, my name is {$ name}, Welcome everyone to read my smarty learning materials.</p> <p>{include file = "foot.tpl"} {* page tail *} ================================== ============== Index.php ================================= =============== <? php / ************************************** **************** file name: index.php * effect: an example routine ** author: big Brother * Email: teacherli@163.com******** ********************************************************* / include_once ("./ Comm / smarty.class. PHP "); // contains a smarty file $ smarty = new smarty (); // Establish a smarty instance object $ smarty $ smarty-> template_dir =" ./Templates";// set template directory $ smarty-> compile_dir = " ./templates_c "; // Set the compilation directory // -------------------------------------- ------------ // Left and right boundary, default is {}, but it is easy to conflict with JavaScript // in practical applications, so it is recommended to set <{}> or others.</p> <p>/ / -------------------------------------------------------------------------------------------- - $ Smarty-> Left_DELIMITER = "{"; $ smarty-> right_delimiter = "}"; $ smarty-> assign ("name", "Li Xiaojun"); // Template variable replacement // compile and display INDEX.TPL Template under ./Templates $ Smarty-> Display ("index.tpl"); "I will display this program as: ================ ================ Execute index.php ================================== == <html> <head> <title> Master Smarty Tutorial </ Title> </ head> <body> Hello, my name is Li Xiaojun, welcome everyone to read my smarty learning materials. <hr> <center> Copyright (c) by Master Email: Teacherli@163.com </ center> <hr> </ body> </ html> instance 2: This example is integrated using Smarty Template parameters One example, these parameters are used to control the output of the template, I only select some of them, other parameters you will go see the reference.</p> <p>======================================================== xample2. TPL ================================================= < HTML> <head> <title> Master Smarty Example 2 </ Title> </ head> <body> 1. The first letter should be capitalized: {$ str1 | Capitalize} <br> 2. Second sentence variable Li Xiaojun: {$ str2 | Cat: "Li Xiaojun"} <br> 3. The third sentence Output Current date: {$ str3 | DATE_FORMAT: "% y year% M month% D day"} <br> 4. Fourth Sen. The php program is not processed, it shows the default value: {$ str4 | default: "No value!"} <br> 5. The fifty sentence wants to indent 8 blank alphanumeric bits, and use "*" to take For these 8 blank characters: <br> {$ str5 | indent: 8: "*"}} <br> 6. The sixth sentence transfers all to lowercase: {$ str6 | lower} <br > 7. The seventh sentence replaces TEacherli in the variable: Li Xiaojun: {$ STR7 | Replace: "Teacherli": "Li Xiaojun"} <br> 8. The eighth sentence is a combination of variable modifiers: {$ str8 | Capitalize | Cat: "Here is the new time:" | DATE_FORMAT: "% y year% M month% D day" | lower} </ body> </ html> ============= ================================== ==================== =================================== <</p> <p>PHP / ********************************************************* file name: example2.php * role: ** 2 shows an example of the program: big Brother * Email: teacherli@163.com*********************** *********************** / include_once ("./ Comm / Smarty.class.php"); // contains smarty file $ smarty = new smarty (); // Establish a smarty instance object $ smarty $ smarty-> template_dir = "./Templates";// set template directory $ smarty-> compile_dir =" ./Templates_c "; // Settings Compile Directory // --- ------------------------------------- / / Left and right boundary, default is {}, but it is easy to conflict with JavaScript // in practical applications, so it is recommended to set <{}> or other.</p> <p>/ / -------------------------------------------------------------------------------------------- - $ smarty-> left_delimiter = "{"; $ smarty-> right_delimiter = "}"; $ smarty-> assign ("str1", "my name is xiao jun, li."); // Put Str1 Replacement into my name is xiao jun, li. $ Smarty-> assign ("str2", "My name is:"); // Out: My name is: Li Xiaojun $ smarty-> assign ("str3", " AD "); // Output AD AUGM 21 (My Current Time) // $ Smarty-> Assign (" STR4 ","); // When the fourth sentence does not process the default value, if The previous sentence is replaced with "" $ smarty-> assign ("str5", "8 *"); // Fifth sentence output: ******* Front 8 * $ smarty-> Assign ("Str6", "Teacherli@163.com"); // This will output teacherli@163.com $ 4marty-> Assign ("Str7", "this is teacherli"); // Displayed in the template: This is Li Xiaojun $ smarty-> assign ("str8", "here is combining:"); // Compile and display the index.tpl template under ./Templates $ smarty-> display ("eXample2.tpl");? > Final output effect: ============================================== ========= example2.php output effect: ======================================== =================== <html> <head> <title> Master SMARTY Example 2 </ title> </ head> <body> 1. The first sentence Letters to capitalize: my name is xiao jun, li. <br> 2. Second modulation variable Li Xiaojun: My name is: Li Xiaojun <br> 3. The third sentence Output Current Date: AD 21 AD 21 <br></p> <p>4. The fourth sentence is not processed in the PHP program. It shows the default value: no value! <br> 5. The fifter sentence wants to indent 8 blank alphabets, and use "*" to replace these 8 blank characters: <br> ******** 8 * <br> 6. Sixth sentence TEACHERLI@163.com <br> 7. The seventh sentence replaces TEacherli in the variable: Li Xiaojun: This is Li Xiaojun <br> 8. The eighth sentence is combined using variable modification Here is Combining: Here is a new time: August 21, 2004 </ body> </ html> These parameters in the template are called variable modifiers, using these parameters to templates Perform a series of modifications control. Variable modifiers use the "|" and regulator name application modifier, use ":" to separate the modifier parameters. Variable modifiers can be used in combination, as in the eighth sentence, in actual use can be flexible.</p> <p>Example 3. =============================================== === example3.tpl ============================================== ====== <html> <head> <title> Template Some functions </ title> </ head> <body> {* below this paragraph is equivalent to defining a variable UserName *} in the template. Assign var = "username" value = "Master"} A variable inside the template will be displayed: username = {$ usrname} The following line will display 3 checkbox: <br> {html_checkboxes name = "checkbox" VALUES = $ CheckName checked = $ IsChecked output = $ value separator = "<br />"} 3 shown below in the radio line will: <br> {html_radios name = "RadioBox" values ​​= $ RadioName checked = $ IsChecked output = $ VALUE SEPARATOR = "<br />"} The following shows a month, day, annual selection box: <br> {html_select_date} <hr> <b> Copyright (c) by xiaojun, Li 2004 <b> {mailto address = "teacherli@163.ccom" text = "Contact the author"} </ body> </ html> ============================== ========================== ====================================================================================================================================================================================================================================== ================</p> <p>================== <? PHP / *********************************** ******************* file name: example3.php * role: ** 3 shows an example of the program: big Brother * Email: teacherli@163.com**** ************************************************** / Require_once ("./comm/ Smarty.class.php "); $ smarty = new smarty (); $ smarty-> template_dir = './templates/'Dir =' ./Templates_C/ '($ 4MARTY B / ISTERES_C /' - $$. / configs / '; $ smarty-> cache_dir =' ./Cache/' '$$.// ------------------------------------------------------------------------------------------------- -------------------------------------------------- -------------- // Handle {HTML_CHECKBOXES name = "checkbox" value = $ checkname checked = $ ischecked output = value sepator = "<br />"} // --- -------------------------------------------------- ------------------------------- $ smarty-> assign ('checkname ", array (1001 =>" ', 1002 =>' Mathematics', 1003 => 'Foreign Language'); $ Smarty-> Assign ('IsChecked', 1001); // ----------------- -------------------------------------------------- ------------------- // Handle {html_radioes name = "Radiobox" value = $ radioname checked = $ ischecked output = value sepator = " <br /> "} // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------ $ smarty-> assign ( 'Radioname', Array (1001 => '", 1002 =>' Mathematics', 1003 => 'Foreign Language'); $ Smarty-> Assign ('IsChecked', 1001);</p> <p>/ / -------------------------------------------------------------------------------------------- -------------------------------------- // {HTML_SELECT_DATE} No processing will automatically output // -------------------------------------------------- ------------------------------------ $ Smarty-> Display ("EXAMPLE3.TPL");? > ================================================================================================================================================================= ===== example3.php output: ======================================= ================ <html> <head> <title> Template some functions </ title> </ head> <body> {assign var = "username" value "value" value "Master"} Here will display a variable inside the template: username = The line below will display 3 Checkbox: <INPUT TYPE = "CheckBox" Name = "Checkbox []" value = "1000 "> Chinese <br /> <input type =" checkbox "name =" checkbox [] "value =" 1001 "checked =" checked "> mathematics <br /> <input type =" checkbox "name =" Checkbox [] "Value =" 1002 "> Foreign language <br /> below this line will display 3 Radio: <br> <input type =" Radio "Name =" Radiobox [] "Value =" 1000> Language <br /> <Input Type = "Radio" Name = "Radiobox []" Value = "1001" Checked = "Checked"> Mathematics <br /> <input type = "Radio" Name = "Radiobox []" value = "1002"></p> <p>Foreign language <br /> The following shows a month, day, annual selection box: <br> <select name = "DATE_MONTH"> <option label = "january" value = "01"> january </ option> <option label = " February "value =" 02 "> february </ option> <option Label =" march "value =" 03 "> march </ option> <option label =" april "value =" 04 "> april </ option> < Option label = "May" value = "05"> May </ option> <option label = "june" value = "06"> june </ option> <option label = "july" value = "07"> july < / option> <option Label = "August" value = "08" class> August </ option> <option label = "september" value = "09> september </ option> <option label =" October "value =" 10 "> october </ option> <option label =" november "value =" 11 "> november </ option> <option label =" december "value =" 12 "> decEmber </ option> </ Select> <select name = "DATE_DAY"> <option label = "01" value = "1"> 01 </ option> <option label = "02" value = "2"> 02 </ option> <option label = "03" value = "3"> 03 </ option> <option label = "04" value = "4"> 04 </ option> <option label = "05" value = "5"> 05 </ option> <option label = "06" value = "6"> 06 </ option> <option label = "07" value = "7"> 07 </ option> <option label =</p> <p>"08" value = "8"> 08 </ option> <option label = "09" value = "9"> 09 </ option> <option label = "10" value = "10"> 10 </ option> <option label = "11" value = "11"> 11 </ option> <option label = "12" value = "12"> 12 </ option> <option label = "13" value = "13"> 13 </ option> <option Label = "14" value = "14"> 14 </ option> <option label = "15" value = "15"> 15 </ option> <option label = "16" value = " 16> 16 </ option> <option Label = "17" value = "17"> 17 </ option> <option label = "18" value = "18"> 18 </ option> <option label = "19 "value =" 19 "> 19 </ option> <option label =" 20 "value =" 20 "> 20 </ option> <option label =" 21 "value =" 21 "SELECTED =" SELECTED "> 21 < / option> <option Label = "22" value = "22"> 22 </ option> <option label = "23" value = "23"> 23 </ option> <option label = "24" value = "24 "> 24 </ option> <option label =" 25 "value =" 25 "> 25 </ option> <option label =" 26 "value =" 26 "> 26 </ option> <option label =" 27 " Value = "27"> 27 </ option> <option label = "28" value = "28"> 28 </ option> <option label = "29" value = "29"> 29 </ option> <option label = "30" Value =</p> <p>"30"> 30 </ option> <option label = "31" value = "31"> 31 </ option> </ select> <select name = "date_year"> <option label = "2004" value = "2004 "SELECTED =" SELECTED "> 2004 <HR> <B> Copyright (c) by xiaojun, Li 2004 <b> <a href="mailto: tacerli@163.com"> ªªªμ × ÷õ </a> </ body> </ html> Example 3 used some functions built into the smarty template, similar functions can be found in the manual, the method is very simple, you can find it yourself. 4. Template control (if / elseif / else / Endif) ====================================== ================== xPLE4.tpl ============================================================================================================================================================================================= =========================== <html> <head> <title> Template's process control </ title> <head> <body> <table border = "1"> {assign var = "tbcolor" value = "# d4d0c8"} color: {$ tbcolor} <br> {section = loop loop = $ news} {if $ tbcolor == "# D4D0C8 "} <TR BGCOLOR =" {$ TBCOLOR} "> {assign var =" tbcolor "value =" # eeeeee "} {else $ tbcolor ==" #eeeeee "} <tr bgcolor =" {$ tbcolor}> { Assign var = "tbcolor" value = "# d4d0c8"} {/ if} <td> {$ news [loop] .newsid} </ td> <td> {$ news [loop] .newstitle} </ td> <</p> <p>Tr> {/ section} </ TABLE> </ body> </ html> ================================ ======================= ============================= ================================ <? php / ************** ******************************** file name: example4.php * role: ** 4 shows an example of the program: large Brother * email: teacherli@163.com*************************************************** ***** / Require_once ("./comm/smarty.class.php" ); $ Smarty = new smarty (); $ smarty-> template_dir = './Templates/' ($$./templates/'; $ 4MARTYBPOMPILE_DIR = '. / Templates_c / '; $ smarty-> config_dir =' ./configs/'A_ $$./cache/'; $ $- >CACHING = FALSE; $ array [] = array ("newsid" = > "001", "newstitle" => "Article 1 News"); $ array [] = array ("newsid" => "002", "newstitle" => "Article 2 News"); $ array [ ] = array ("newsid" => "003", "newstitle" => Article 3 News "); $ array [] = array (" newsid "=>" 004 "," newstitle "=>" 4th 4 News "); $ array [] = array (" newsid "=>" 005 "," newstitle "=>" Article 5 news "); $ array [] = array (" newsid => "006", "newstitle" =></p> <p>"Article 6 News"); $ array [] = array ("newsid" => "007", "newstitle" => "Article 7 News"); $ array [] = array ("newsid" => " 008 "," newstitle "=> Article 8 News"); $ smarty-> assign ("news", $ array); $ smarty-> display ("eXample4.tpl");?> ===== ========================================================================================================================================================================================== ★ ============================================================================================================================================================================================================= <html> <head> <title> Template </ title> <head> <body> <table border = "1"> <tr bgcolor = "# d4d0c8> <td> 001 </ td> < TD> Article 1 News </ td> </ tr> <trs <TD> 002 </ TD> <TD> Article 2 News </ TD> </ TR> <TR BGColor = "# D4D0C8"> <TD> 003 </ TD> <TD> Article 3 News </ td> </ tr> <tr bgcolor = "#eeeeeee"> <td> 004 </ td> <td> 4th Article </ td> </ tr> <tr bgcolor = "# d4d0c8"> <td> 005 </ td> <td> Article 5 News </ td> </ tr> <tr bgcolor = "#eeeeee" > <TD> 006 </ TD> <TD> Article 6 News </ TD> </ Tr> <TR BGColor = "# D4D0C8"> <TD> 007 </ TD> <TD> Article 7 News </ TD> </ TR> <tr bgcolor = "#eeeeee"> <td> 008 </ td> <TD> Article 8 News <</p> <p>/ TD> </ tr> </ table> </ body> </ html> Template file: {if $ tbcolor == "# d4d0c8"} <tr bgcolor = "{$ tbcolor}"> {assign var = "tbcolor" value = "# eeeeee"} {else $ tbcolor == "#eeeeee"} <TR bgcolor = "{$ tbcolor}> {assign var =" tbcolor "value =" # d4d0c8 "} {/ if} This statement blocks the background color of each row, {assign var = "tbcolor" value = "# d4d0c8"} is also remembering, it is the definition method of setting the internal variable in Example 3, using a template built-in process control statement Sometimes it can greatly improve the ability to control the program. One example below is phpx.com has been asked. I put it as an instance for everyone to learn. Example 4 I used {IF / Elseif The method of use of / else / if}, if you use this sentence in order to achieve the purpose of your own, you can use this sentence: PHP code: ---------------------- -------------------------------------------------- -------- {Section name = rows loop = $ data} <tr bgcolor = "{cycle value =" # D4D0C8, # eeeee "}"> <td> {$ data [rows]} </ td > </ tr> {/ section} ----------------------------------------- ---------------------------------------- Example 5: Use the template built-in process control statement A multi-cell content output, that is, several records per recorded in the visual smarty: =============================== ================== xiMple5.tpl =============================================================================================================================================================================================================================== =================== <html> <head> <title> Your line output multiple records </ title> </ head> <body> <table> <tr> {section name = loop loop = $ news step = 1} {if $ smarty.section .loop.index% 4 == 0} </ tr> <tr> {/ if} <td></p> <p>{$ News [loop] .newsid} </ td> <td> {$ news [loop] .newstitle} </ td> {/ section} </ tr> </ table> </ body> </ html> = ============================================================================================================================================================================================================= = esample5.php ================================================= ====== <? PHP / ************************************************** ******* file name: example5.php * role: ** 5 shows an example of the program: big Brother * Email: teacherli@163.com**************** *************************************** / Require_once ("./comm/smarty.class.php"" $ $MARTY = NEW Smarty (); $ smarty-> template_dir = './templates/'. ($$$$$ ./Templates_C/'A; $$$ ($' ./configs/dir = './configs/'; $ $ 中> >cache_dir =' ./cache/'Caching = false; $ array [] = array ("newsid" => "001", "newstitle" => Article 1 News "); $ array [] = array ( "newsid" => "002", "newstitle" => "Article 2 News"); $ array [] = array ("newsid" => "003", "newstitle" => "Article 3 News") $ array [] = array ("newsid" => "004", "newstitle" => "Article 4 News"); $ array [] = array ("newsid" => "005", "newstitle" = > "Article 5 News"); $ array [] = array ("newsid"</p> <p>=> "006", "newstitle" => "Article 6 News"); $ array [] = array ("newsid" => "007", "newstitle" => "Article 7 News"); $ array [] = array ("newsid" => "008", "newstitle" => "Article 8 News"); $ smarty-> assign ("news", $ array); $ smarty-> display ("eXample5. TPL ");?> ============================================= ====== example5.php output content: ========================================= ============ <html> <head> <title> One line output multiple records </ title> </ head> <body> <Table> <TR> </ TR> <TR> <TD> 001 </ TD> <TD> Article 1 News </ TD> <TD> 002 </ TD> <TD> Article 2 News </ TD> <TD> 003 </ TD> <TD> 3 News </ TD> <TD> 004 </ TD> <TD> Article 4 News </ TD> </ TD> <TD> <TD> 005 </ TD> <TD> Article 5 News </ TD> <TD> 006 </ TD> <TD> Article 6 News </ TD> <TD> 007 </ TD> <TD> Section 7 News </ TD> <TD> 008 </ TD> <TD > Article 8 News </ TD> </ TR> </ Table> </ body> </ html> Description: Originally optimized, make the first line does not output <TR> </ TR> of an empty line, But the learning program, simple is good, first use it first. Here, explain: {section name = loop loop = $ news step = 1} {if $ smarty.section.loop.index% 4 == 0} </ Tr> <tr> {/ if} <td> {$ news [loop] .newsid} </ td> <td></p> <p>{$ News [loop] .newstitle} </ td> {/ section} {section} {/ section} Refers to a loop section, in the next section, there will be a detailed introduction, we mainly take a look at this sentence: {IF $ smarty.section.loop.index% 4 == 0} $ smarty.section.loop Indicates a section called loop in the section section of $ smarty, it has a property called index, its representation of the current loop Value, starting from 0, we compare it to 0 after a% 4, that is, if the current index value is a multiple of 4, it outputs </ TR> <TR>, otherwise the following part is performed. It is very simple to solve a very troublesome thing to implement in the program. Here I only demonstrate how to use {if} statement features, implement this feature there is also a very convenient way in smarty template: {cycle} The examples are used as follows: ================================= {section name = rows loop = $ data } <tr bgcolor = "{cycle value =" # D4D0C8, # eeeee "}"> <td> {$ data [rows]} </ td> </ tr> {/ section} ======== ========================= from:</p> <p>http://xjtusky.net/Article/htmldata/2004_10/3/57/Article_850_1.html</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-84145.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="84145" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.039</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'SpX52Lw0I2Fd11VljCFldThWKay6GMiGgy7euQ_2BYClN0T2OToMzyejwLcoDqFP3bob8cG2sKqwb0C8Pi_2B6IviA_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>