Simple smarty template class

Source: Internet
Author: User

A simple smarty template class requires only one file. Thank you for choosing ecshop.

TestCode:

 Require_once 'Cls _ template. php' ;  $ Smarty = New  Cls_template;  $ Smarty -> Cache_lifetime = 30 ;  $ Smarty -> Template_dir = Dirname ( _ File __ ). '/Cache/smarty/template /' ; $ Smarty -> Cache_dir = Dirname ( _ File __ ). '/Cache/smarty/Cache /' ;  $ Smarty -> Compile_dir = Dirname ( _ File __ ). '/Cache/smarty/compiled /' ;  $ Smarty -> Direct_output = False  ;  $ Smarty -> Force_compile = True ;  $ Array = Array (1, 2, 3, 4, 5 );  $ Smarty -> Assign ('array ', Array  ( 'Egw _ polls' => Array  ( 'Fd '=> Array  ( 'Poll _ id' => Array ('Type' => 'auto', 'nulllable' => False ), 'Poll _ title' => Array ('Type' => 'varchar ', 'precision' => '000000', 'nulllable' => False ), 'Poll _ timestamp' => Array ('Type' => 'int', 'precision '=> '8', 'nulllable' => False ), 'Poll _ visable' => Array ('Type' => 'int', 'precision '=> '4', 'nulllable' => False , 'Default' => '0'), 'Poll _ votable' => Array ('Type' => 'int', 'precision '=> '4', 'nulllable' => False , 'Default' => '0 '), ) , 'Pk' => Array ('Poll _ id'), 'fk '=> Array (), 'Ix '=> Array (), 'Uc' => Array  ()) , 'Egw _ polls_answers' => Array  ( 'Fd '=> Array  ( 'Answer _ id' => Array ('Type' => 'auto', 'nulllable' =>False ), 'Poll _ id' => Array ('Type' => 'int', 'precision '=> '4', 'nulllable' => False ), 'Answer _ text' => Array ('Type' => 'varchar ', 'precision' => '000000', 'nulllable' => False ), 'Answer _ votes '=> Array ('Type' => 'int', 'precision '=> '4', 'nulllable' => False , 'Default' => '0 '), ) , 'Pk' => Array ('Answer _ id'), 'fk '=> Array (), 'Ix '=> Array ('Poll _ id'), 'uc' => Array  ())));  $ Smarty -> Assign ('name', 'omnitrix' );  $ Smarty -> Assign ('user ', Array ('Name' => 'admin', 'Password' => '000000', 'email '=> 'admin @ admin.com' ));  $ Smarty -> Display ('T1. TPL ');

 

Test template:

<Br/> name :{ $ Name  } <Br/> admin :{ $ User . Name} <Br/> password :{ $ User . Password} <Br/> Email :{ $ User . Email | Upper | escape: URL }{  Foreach From = $ Array   Key = Table_name item = table_info name = ABC} <Br/> {$ Table_name }:{ $ Smarty . Foreach . ABC. First }:{ $ Smarty . Server. Php_self} {foreachelse} <Br/> nothing. { / Foreach }

 

The class file cls_template.php is located in ecshop/schemdes. You can find it after downloading the source code of ecshop.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.