ideas for the smarty class file

From: Date: Thu, 20 Feb 2003 18:11:15 +0000
Subject: ideas for the smarty class file
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-776@lists.php.net to get a copy of this message
FIRST OF ALL, I want to preface the ideas/comments below with: 'great job all of you!' I have begun using it and it is a fantastic piece of software. It sets the trend for years to come for this kind of purpose. I believe that is will become a major building block for additional PHP projects, more so than it is now. THANK YOU, ALL OF YOU for building this. ------------------------------------------------------------------- Now to some input/suggestions on the smarty.class.php file ..... ------------------------------------------------------------------- 1/ add comments to the line: define('DIR_SEP', DIRECTORY_SEPARATOR); to explain whether this is the: '/'vs '\' situation, or the ':' vs ';' situation what the purpose of this definition is, where DIRECTORY_SEPARATOR is to come from, or what to use it for? 2/ In order to make starting up for us beginning users much easier, I propose these additional changes: A/ Put the following definitions below the define line above in the smarty class definition. (as far as these names go, see comments at bottom ) define('SMARTY_DEFAULT_TEMPLATE_DIR', "templates"); define('SMARTY_DEFAULT_COMPILE_DIR', "templates_c"); define('SMARTY_DEFAULT_CONFIG_DIR', "configs"); define('SMARTY_DEFAULT_CACHE_DIR', "cache"); define('SMARTY_DEFAULT_PLUGINS_DIR', "plugins"); define('SMARTY_DEFAULT_DEBUG_TPL', "debug_tpl"); B/ Put the following lines at the top of the smarty constructor: ( manually wrapped to appear better in a mail client ) if( !isset($this->template_dir )) $this->template_dir = SMARTY_DIR . SMARTY_DEFAULT_TEMPLATE_DIR; if( !isset($this->compile_dir )) $this->compile_dir = SMARTY_DIR . SMARTY_DEFAULT_COMPILE_DIR; if( !isset($this->config_dir )) $this->config_dir = SMARTY_DIR . SMARTY_DEFAULT_CONFIG_DIR; if( !isset($this->cache_dir )) $this->cache_dir = SMARTY_DIR . SMARTY_DEFAULT_CACHE_DIR; if( !isset($this->plugins_dir )) $this->plugins_dir = array(SMARTY_DIR . SMARTY_DEFAULT_PLUGINS_DIR); if( !isset($this->debug_tpl )) $this->debug_tpl = SMARTY_DIR . SMARTY_DEFAULT_DEBUG_TPL; C/ Change the values of the class variables in the class defintion to unset/nothing as per: var $template_dir; var $compile_dir; var $config_dir; var $cache_dir; var $plugins_dir; var $debug_tpl; 3/ Items 2A - 2C above, will cover the following circumstances; A/ If the class is used raw, and not extended, then the values will come out the same as they do now, with one exception, the value $debug_tpl. I COULD USE SOME IDEAS ON THIS ONE. Why is there a debug.tpl in the smarty distribution, but it's not referenced? B/ if the class is extended and the constructor for the extended class assigns values to the above six variables, they will be left alone when the child constructor then calls the parent constructor in the smarty class. C/ any code that now assigns the variables through $smarty_object_name->var_name = var_value will still overwrite the values in the class variables. D/ us newbies or even those wishing to have very flexible code, set the constant, 'SMARTY_DIR', as per the directions and tutorials, and all the correct files and directories can be reached. MUCH fewer, 'help me, I get such and such error upon new installation' emails as a result, and a MUCH better first impression of Smarty also. As it is 'SMARTY_DIR' has very little usage, except for having to write it in manually all over the place. 4/ Why is debug_tpl set up to be both path and file name, instead of looking for it in $templates_dir ? I think if that flexibility is needed, a separate variable for $debug_templates should be made. Shouldn't all templates be in $template_dir otherwise? 5/ picyaune notes here. $template_dir is 'templates' --- SINGULAR var name, PLURAL path name path IS named after contents $compile_dir is 'templates_c --- SINGULAR var name, PLURAL path name path IS NOT named after contents $config_dir is 'configs' --- SINGULAR var name, PLURAL path name path IS named after contents $cache_dir is 'cache' --- SINGULAR var name, SINGULAR path name path IS named after contents $plugins_dir is 'plugins' --- PLURAL var name, PLURAL path name path IS named after contents $debug_tpl is '' --- starts out blank, but a default template exists is for both a DIRECTORY and FILE name, not a directory OR a file name. 6/ If changes to class vars were to be made for consistency, I would suggest the following: $templates_dir is 'templates' --- PLURAL var name, PLURAL path name path IS named after contents $templates_compiled_dir is 'templates_c' --- PLURAL var name, PLURAL path name path IS named after contents $configs_dir is 'configs' --- PLURAL var name, PLURAL path name path IS named after contents (THERE ARE MULTIPLE CACHE DIRECTORIES OR 'CACHES',MAKE THESE PLURAL? $caches_dir is 'caches' --- PLURAL var name, SINGULAR path name path IS named after contents $plugins_dir is 'plugins' --- PLURAL var name, PLURAL path name path IS named after contents $debug_tpl_file is 'debug.tpl' --- FILE NAME (MAYBE THIS WILL REQUIRE A SEPARATE CACHE? I DON'T THINKS SO, I'D JUST CHANGE THE ASSUMED LOCATION OF THE DEBUG TEMPLATE TO EITHER: A/ $templates_dir B/ or $templates_dir . 'debug' $templates_debug_dir is 'templates' -OR- $templates_debug_dir is 'templates/debug'

« previous php.smarty.dev (#776) next »