Re: [SMARTY] Re: I found a BUG in Smarty!

From: Date: Thu, 16 May 2002 14:38:42 +0000
Subject: Re: [SMARTY] Re: I found a BUG in Smarty!
References: 1 2 3 4  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-4230@lists.php.net to get a copy of this message
It depends on what your included php file is doing. In our experience, {include_php} is useful for the componentized templates ideology outlined in the manual. (That is what it was created for anyways.) In this case all it is doing is registering functions, so you would only want to include it once. But aside from what one thinks an included php script should and should not do, maybe the decision to include once or not should not be up to Smarty, but up to the included PHP script to handle whether it has already been included or not: if(!isset($_nav_loaded)) { // do stuff, register funcs $_nav_loaded = true; } Or, we could provide a way to specify whether the file is included once or not with a parameter. {include_php file="test.php" include_once=false} Thoughts? Monte Johann wrote:
On 16 maja 2002 at 15:36:27 Ivo Jansch <ivo@ibuildings.nl> wrote:
But can you show me any working example of posibly errors when you change those 2 lines from include_once() to include()?
Yeah. Put this inside your test.php:
function test() { }
Your patch will fail with a 'already defined' error message.
You have right... It does not work for defined function or classes. Otherwise it should work. There are cons and pros. If you have include_once statement than nested templates cannot put their external files for their php code. But if you have include statement than defined classes (or functions) will not work and code will fail. So... maybe, the best solution is to add an optional parameter to {include_php} as it was mentioned. (It would be good to add small info about such possibly problems with nested templates to manual as well). -- Johann
-- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc.

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