盱眙在仕德伟做网站的有几家wordpress 改相对路径
news/
2025/9/22 17:33:29/
文章来源:
盱眙在仕德伟做网站的有几家,wordpress 改相对路径,本人已履行网站备案信息,洋县建设银行网站Yaf 结合用户自定义的视图(模板)引擎Smarty(Yaf Smarty)来源#xff1a;互联网作者#xff1a;佚名时间#xff1a;2015-08-06 07:55对完成某个任务进行计时可使用progress_timer类#xff0c;这个类对象在退出作用范围后#xff0c;会输出对象创建后过去的时间#xff…Yaf 结合用户自定义的视图(模板)引擎Smarty(Yaf Smarty)来源互联网作者佚名时间2015-08-06 07:55对完成某个任务进行计时可使用progress_timer类这个类对象在退出作用范围后会输出对象创建后过去的时间可申请多个类对象这样可对多个任务进行统计。#incYaf 结合用户自定义的视图(模板)引擎Smarty(Yaf Smarty)分类php开发yafsmarty(1)入口文件/public/index.php:define(DS, /);define(APPLICATION_PATH, dirname(__FILE__).DS....DS);//指向public上一级的目录 ../$application new Yaf_Application( APPLICATION_PATH . /conf/application.ini);$application-bootstrap()-run();?(2)在引导程序class Bootstrap extends Yaf_Bootstrap_Abstract{public function _initConfig() {//把配置保存起来$arrConfig Yaf_Application::app()-getConfig();Yaf_Registry::set(config, $arrConfig);}//其他定义忽略......public function _initSmarty(Yaf_Dispatcher $dispatcher) {//init smarty view engine$smarty new Smarty_Adapter(null, Yaf_Registry::get(config)-get(smarty));$dispatcher-setView($smarty);}}(3)添加类使Smarty_Adapter首先下载vim Adapter.php/*确保Smarty.class.php在Smarty/libs/下*/Yaf_Loader::import( Smarty/libs/Smarty.class.php); /*基类目录为library*/class Smarty_Adapter implements Yaf_View_Interface /*Smarty_Adapter类为yaf与smarty之间的适配器*/{/*** Smarty object* var Smarty*/public $_smarty;/*** Constructor** param string $tmplPath* param array $extraParams* return void*/public function __construct($tmplPath null, $extraParams array()) {$this-_smarty new Smarty;if (null ! $tmplPath) {$this-setScriptPath($tmplPath);}foreach ($extraParams as $key $value) {$this-_smarty-$key $value;}}/*** Return the template engine object** return Smarty*/public function getEngine() {return $this-_smarty;}/*** Set the path to the templates** param string $path The directory to set as the path.* return void*/public function setScriptPath($path){if (is_readable($path)) {$this-_smarty-template_dir $path;return;}throw new Exception(Invalid path provided);}/*** Retrieve the current template directory** return string*/public function getScriptPath(){return $this-_smarty-template_dir;}/*** Alias for setScriptPath** param string $path* param string $prefix Unused* return void*/public function setBasePath($path, $prefix Zend_View){return $this-setScriptPath($path);}/*** Alias for setScriptPath** param string $path* param string $prefix Unused* return void*/public function addBasePath($path, $prefix Zend_View){return $this-setScriptPath($path);}/*** Assign a variable to the template** param string $key The variable name.* param mixed $val The variable value.* return void*/public function __set($key, $val){$this-_smarty-assign($key, $val);}/*** Allows testing with empty() and isset() to work** param string $key* return boolean*/public function __isset($key){return (null ! $this-_smarty-get_template_vars($key));}/*** Allows unset() on object properties to work** param string $key* return void*/public function __unset($key){$this-_smarty-clear_assign($key);}/*** Assign variables to the template** Allows setting a specific key to the specified value, OR passing* an array of key value pairs to set en masse.** see __set()* param string|array $spec The assignment strategy to use (key or* array of key value pairs)* param mixed $value (Optional) If assigning a named variable,* use this as the value.* return void*/public function assign($spec, $value null) {if (is_array($spec)) {$this-_smarty-assign($spec);return;}$this-_smarty-assign($spec, $value);}/*** Clear all assigned variables** Clears all variables assigned to Zend_View either via* {link assign()} or property overloading* ({link __get()}/{link __set()}).** return void*/public function clearVars() {$this-_smarty-clear_all_assign();}/*** Processes a template and returns the output.** param string $name The template to process.* return string The output.*/public function render($name, $value NULL) {return $this-_smarty-fetch($name);}public function display($name, $value NULL) {echo $this-_smarty-fetch($name);}}?(4)修改vim application.ini[common]application.directory APPLICATION_PATH /applicationapplication.dispatcher.catchException TRUEapplication.bootstrap APPLICATION_PATH /application/Bootstrap.phpapplication.library APPLICATION_PATH /application/libraryapplication.baseUri ;application.dispatcher.defaultModule indexapplication.dispatcher.defaultController indexapplication.dispatcher.defaultAction index;errors (see Bootstrap::initErrors)application.showErrors0[smarty : common]application.view.exttpl ;;设置视图文件的后缀为 tpl;smarty.left_delimiter {{ ;设置模板提取值时候的{情况;smarty.right_delimiter }} ;smarty.template_dir APPLICATION_PATH /application/views/smarty.compile_dir APPLICATION_PATH /application/views/templates_c/smarty.cache_dir APPLICATION_PATH /application/views/templates_d/;smarty.caching 0;;smarty.cache_lifetime 600;[product : smarty](5)基于Yaf Smarty
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/909824.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!