Instance Learning PHP FastTemplate Template

xiaoxiao2021-03-06  120

Instance Learning PHP FastTemplate Template

If you have never touched PHP, then look at this first, of course, even if you have already understood the PHP, a PHP4 manual is still needed, :). In addition, a HTML syntax manual is of course an indispensable. . . . . . . . . . Do you often face the distress of the revision in the development process? Hundreds of thousands of documents are required for all the small changes on the layout, is it unpredictable? Hey, if you can separate the content and expressions, this is always waiting. But unfortunately, XML used to deal with this problem is not completely mature. Is there any way? As the so-called thing is dead, people are alive, and the PHP library we have to learn today can help us to deal with this issue to a certain extent. :)) What is fastTemplate? From the PHP language, it is a PHP library; from its origin, it comes from a PERL package that is the same name; it is a utility that allows you to change the entire site appearance in a few seconds. In the most popular language, it is a template, a template similar to Dreamwaver. Now fastTemplate is a question mark in your heart? Still an exclamation point? Or is it a period? (Editor: Rely, in this deceive fee, I am flat!) Forget, no matter how much, you just know that he is a good thing, :) First before we use this library, you must download it first, everyone can Below this website http://www.thewebmasters.net/php/ Download it (this site download address is: http://www.phpe.net/downloads/1.shtml).

After downloading it, remove it into a directory of your web server, below is the decompressed directory structure fastTemplate-1.1.0 / fasttemplate-1.1.0 / readme <- This file doesn't have to say it? FastTemplate-1.1.0 / class.fastTemplate.php3 <- This file is most important, it is in the library file, the core Lord! FastTemplate-1.1.0 / example_1.phtml <- an example fastTemplate-1.1.0 / example_2.phtml <- second example fasttemplate-1.1.0 / example_3.phtml <- third example fasttemplate-1.1.0 / dynamic_example .phtml <- Fourth Example FastTemplate-1.1.0 / DOCS / <- Document Directory FastTemplate-1.1.0 / DOCS / FASTTEMPLATE.3 <- UNIX Man Page FastTemplate-1.1.0 / DOCS / FASTTEMPLATE.HTML <- HTML Documentation fastTemplate-1.1.0 / templates / <- TabletTemplate-1.1.0 / templates / principal-1.1.0 / templates / main.tpl fastTemplate-1.1.0 / templates / header.tpl fastTemplate-1.1.0 / templates / main.tpl fasttemplate- 1.1.0 / templates / row.tpl fasttemplate-1.1.0 / templates / test.tpl fastTemplate-1.1.0 / templates / footer.tpl fasttemplate-1.1.0 / templates / htaccess.tpl fasttemplate-1.1.0 / templates / Middle.tpl fastTemplate-1.1.0 / templates / table.tpl pay attention to, this directory must be the directory of PHP programs to access 哟, in other words, the include directory in php.ini. Then, friends who have been programmed with PHP4 are noticed, you can't use this library directly, you still need to make some modifications! Pay attention to the following. PHP3 readers don't have to manage so much, you can try the examples it belt now, (嘿, but, it's the suffix name of those examples is PHTML, if you can't set the web. You can try Conversion to the suffix name, it should also be used, and there is no tried dare to make the ticket.

)that! Then, the brothers of PHP4 should pay attention to 哟, if you don't press the following modified words, this library has no way to use! ! --- Class.fastTemplate.php3 Sun Jun 27 13:44:47 1999 php4.fastTemplate.php3 Tue Jul 20 10:49:25 1999 @@ -196, 8 196, 10 @@ settype ($ VAL , "String");} - $ TEMPLATE = EREG_REPLACE ("{$ Key}", "$ VAL", "$ Template"); - // $ Template = STR_REPLACE ("{$ key}", "$ val" "$ Template"); // php4 doesn't like '{$' Combinations. $ key = '{'. "$ key". '}'; $ template = EREG_REPLACE ("$ key", " $ VAL, "$ Template"); / $ template = STR_REPLACE ("$ key", "$ val", "$ template");}} @@ -410, 7 412 ,7 @@} IF ($ END) {- $ newparent. = "{$ macroname}"; $ newparent. = '{'. "$ macroname}";} // next line please if ($ end) {$ END = false;} Everyone uses the text editor to open the class.fastTemplate.php3 file, find the above part. '-' minus the representative to eliminate this line, the ' ' plus sign representative to join this line. In addition, friends under the Windows system should pay attention! You also need to change some small things, change the value of the $ Win32 variable below to True, don't change, you can't use it, don't marry me,;). Var $ Win32 = true; // set to true if this is a win32 server, you can try his examples. how is it? Successful.嘿嘿 嘿 ~~~, hidden will not lie to everyone. OK, now this library is already available, we are ready to do the following, :) How to use this library? Simple, first put this library into in.

That is to say, want to include "class.fastTemplate.php3"; then? Oh ... then I don't know! (Editor: "Hey! Looking for Flat, you!"), Ah ...! Sorry, I remembered (after the hiding of the house, the sea is edited). Then learn the principle of using this library. Here, let us first make a hypothesis. We assume that a page consists of many small parts (such as: each site has a column navigation, etc.), and each small part has a unique identifier (for example: we put the column. Item Definition as a name) We first take this library as an example, let everyone learn the basic usage of this library as soon as possible, but everyone should pay attention to 哟, these documents are in the server position to press If you decompress the relative path, don't forget, just like you don't forget your girlfriend.

Ha ha ~~~~ Define (Array (main => "main.tpl", table => "Table.tpl", row => "row.tpl")); $ TPL-> Assign (Array (Title => "FastTemplate Test")); for ($ n = 1; $ n <= 3; $ n ) {$ Number = $ N; $ Bignum = $ N * 10; $ TPL-> Assign Array (Number => $ Number, Big_Number => $ BIGNUM); $ TPL-> Parse (Rows, "Row");} $ TPL-> PARSE (Main, Array ("Table", "Main")) $ TPL-> fastprint (); exit;?> {title} </ title> </ head> <body> {main } </ Body> </ html> <! - Name: Table.tpl -> <Table Border = '1'> {rows} </ table> <! - End: Table.tpl -> <! - name: row.tpl -> < Tr> <TD> {Number} </ td> <td> {big_number} </ td> </ tr> -> Row.tpl -> Using this library first, please asked in the previous Class.fastTemplate.php3 "; then define the template where $ TPL = new fasttemplate (" ./ Templates "); pay attention! Here I am running in the Windows system, so it is possible to use "./templates", in Linux or UNIX, you may not be the same, everyone is set according to the specific situation. Then, we correspond to different templates, define the following matrix array.</p> <p>$ TPL-> Define (Array (main => "main.tpl", table => "Table.tpl", ROW => "Row.tpl"); define is a function in this class. Below is its syntax: Define (es "), define () function maps a name to the template file, this new name will be the only name you used to represent the template, because this is not There will be a template file name. And everyone pays attention, this is the steps that cannot be lacking, can't be less, if less, then don't bring your birthday gift to your girlfriend's birthday party, 嘿嘿 ~~~~ now ! The key, the most personality is coming! Assign (Key, Value Pair) This function will define the identifier defined in the template to really want something on your web. For example, it is the above $ TPL-> Assign (Title => "fasttemplate test"); this sentence, replacing the {title} in template main.tpl to find you don't understand what you want to see, you can see the code above. Next! It is another very distinctive stuff.Parse (Return, FileHandle (s)) defines a defined template to another template file. Everyone carefully study the following code, I believe it is easier to understand. For ($ n = 1; $ n <= 3; $ n ) {$ number = $ n; $ bignum = $ n * 10; $ TPL-> Assign (Array (Number => $ Number, BIG_NUMBER => $ BIGNUM); $ TPL-> PARSE (Rows, "Row");} Parse has three functions $ TPL-> PARSE (Main, "main"); // Standard $ TPL-> PARSE (Main, Array " , "main")); // Simple $ TPL-> PARSE (Main, ".row"); // Increase in the third most interesting, it represents, add one on the basis of it. New data.</p> <p>Oh, I said that everyone may not understand, let's take a look at the above source code, after all, there are many things that are only available! (The instructions in English are attached, not to be lazy, do not translate, and there is something more easily understood than the translation. In The Regular Version, The Template Named `` main '' is loaded if it hasn ' t been already, all the variables are interpolated, and the result is then stored in FastTemplate as the value MAIN. If the variable '{MAIN}' shows up in a later template, it will be interpolated to be the value of the parsed ` .. `main '' template This allows you to easily nest templates, which brings us to the compound style The compound style is designed to make it easier to nest templates The following are equivalent:. $ tpl-> parse (mAIN," table "); $ TPL-> PARSE (Main," .main "); // is The Same AS: $ TPL-> PARS (Main, Array (" Table "," Main ")); // this Form Saves Function calls and makes your code cleaner It is important to note that when you are using the compound form, each template after the first, must contain the variable that you are parsing the results into. In the above example, 'main' must conta In The Variable '{main}', as there is where the pased results of 'table' is stored. if 'main' does not contact the variable '{main}' TENTE PARSED RESULTS OF 'TABLE'</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-126632.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="126632" 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.031</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 = 'tyRxqEi4_2BfdmckpiEJmFC9yU0fzqpJAwzgJGOtdU3BLfU1FX2Z4lXcV6sAElnh2_2BZZxrxiI92pB_2BQzRy'; 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>