Re: SV: [SMARTY] bug in block_function handling?

From: Date: Thu, 21 Oct 2004 10:40:30 +0000
Subject: Re: SV: [SMARTY] bug in block_function handling?
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11908@lists.php.net to get a copy of this message
On Thu, Oct 21, 2004 at 12:31:03PM +0200, Paolo Nesti Poggi wrote: > Hi again > Yesterday, answering to Boots I was to quick in my optimism. Actually the > problem was not solved. The confusion was probably due the fact that I had > copied the plugin from the custom_plugin directory and the plugin in the > plugin directory might have been the one working at a certain point in time. > > Today I've done some sistematic testing and found that the error is still > there. I'll try and give a clear description as I run it through. > > If I understand you right Monte, following your email I don't even need to > register the block function provided that the plugin follows the naming > convention for both the function name and the file name, even if it doesn't > resides in one of the the plugin directories. > > So actually we have three behaviours: > 1. autoincluded and autoloaded -> plugin following naming convention and > within plugin directories yes. > 2. autoloaded -> plugin following the naming convention, residing outside of > the plugin directories no. to my knowledge that doesn't work. maybe monte mixed that up with {insert}. > 3. needing registration - > plugin not following the naming convention for > function name (but positive for file name) and residing wherever in the > application yes. BTW: do you clear your templates_c and your cache-directory between these tests? you should do that when switching around plugin-registrations or confusion will never end :) greetings messju > I tested the 2 situations where I can disable caching for the plugin, as > this is what I want to accomplish (case 2 and 3), and I know case 1 is > working. The results are provided below. The way I'm doing the test is: > a) clearing the Smarty_templates_c directory (rm -rf *) > b) running the application once or several times with the smarty settings > below (caching disabled) > ( I post a form, the block includes a script that catches the posted > content) > $this->compile_check=true; > $this->force_compile=true; > $this->caching=false; > > c) enabling caching with > $this->compile_check=true; > $this->force_compile=false; > $this->caching=true; > d) Reloading the posted form, or posting another time. > > And here is the test result > > In case 3 (registration needed) > In the application I have: > include_once('Smarty/Smarty_nocache_cmpt/block.nc.php'); > $smartyDisplay->register_block('nc', 'php_component_nc', false); > > the function is: > function php_component_nc($params, $content, &$this) > { > ... > } > and the template has: > {nc}...{/nc} > > It runs ok with no caching, when I enable caching as by point c) above I > get the following error: > > Fatal error: Smarty error: [in candidate/it.tpl line 29]: [plugin] could not > load plugin file 'block.nc.php' (core.load_plugins.php, line 118) in > /usr/share/munk_php/Smarty-2.6.6/libs/Smarty.class.php on line 1088 > > > In case 2: > In the application I have: > include_once('Smarty/Smarty_nocache_cmpt/block.nc.php'); > // commented out because not needed: $smartyDisplay->register_block(...); > > the function is: > function smarty_block_nc($params, $content, &$this) > { > ... > } > and the template has: > {nc}...{/nc} > > Here I do get an error even when caching is disabled > The error is: > Fatal error: Smarty error: [in candidate/it.tpl line 29]: syntax error: > unrecognized tag 'nc' (Smarty_Compiler.class.php, line 565) in > /usr/share/munk_php/Smarty-2.6.6/libs/Smarty.class.php on line 1088 > > What do you think? > > Regards, Paolo > > > > > -----Oprindelig meddelelse----- > > Fra: Monte Ohrt [mailto:monte@ispi.net] > > Sendt: 20. oktober 2004 23:02 > > > Manually registered plugins (functions/modifiers/etc...) do not need to > > follow a function-name naming convention. However, a function inside an > > auto-loaded plugin DOES need to follow the function-name naming > > convention so Smarty can find it. > > > > So, if you have a plugin file named function.foobar.php in your plugins > > directory and you expect it to work when you put {foobar} in the > > template, then the function name HAS to be smarty_function_foobar() in > > the plugin file. However, if you have the function my_foobar() somewhere > > in your application and want it to handle the {foobar} template tag, > > then you just register it with > > register_function('foobar','my_foobar'); > > Or alternately, name it with the naming convention > > smarty_function_foobar() and it will automatically work with no plugin > > and no registration necessary. > > > > Monte > > > > > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

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