Smarty 1.4.0 modifications

From: Date: Mon, 14 May 2001 12:15:58 +0000
Subject: Smarty 1.4.0 modifications
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-755@lists.php.net to get a copy of this message
Hi, I've made some modifications to Smarty 1.4.0. Please have a look to see if you can put this in 'official' Smarty. 1) In the _fetch_template_source function, I added a line of code that appends the template extension if the user forgot it: if (substr($resource_name,-(strlen($this->tpl_file_ext)))!=$this->tpl_file_ext) $resource_name.=$this->tpl_file_ext; (I use this because I must be able to do an {include file=$template} where $template contains the name of the template without extension) 2) In _smarty_include, I added the following lines (just above the extract($this->_tpl_vars) line): if (is_array($_smarty_include_vars["local"])) { $this->_tpl_vars = array_merge($this->_tpl_vars, $this->_tpl_vars["local"]); } This has the following result: If you include a template, you can make variables appear 'local' to that template, even when the data is in some complex datastructure in the main template. Example main.tpl: This is the book: {$book.title} <br>{include file=author.tpl local=$book.author} And this is the movie: {$movie.title} <br>{include file=author.tpl local=$movie.author} author.tpl: <b>{$name}</b> {$birthdate} All variables from $book.author or $movie.author are now 'local' to the author template, and the person designing author.tpl does not need to know whether he's creating a template for $book.author or $movie.author or... Since these 2 modifications don't break anything and might be useful for other users too, you might want to consider putting this in the code. (Which would also save me from having to re-apply these modifications to each new Smarty version you release :) Greetings, Ivo -- Ivo Jansch <ivo@ibuildings.nl> ibuildings.nl BV - information technology http://www.ibuildings.nl

« previous php.smarty.general (#755) next »