SV: [SMARTY] bug in block_function handling?
| From: | Paolo Nesti Poggi | Date: | Wed, 20 Oct 2004 21:39:39 +0000 |
| Subject: | SV: [SMARTY] bug in block_function handling? | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-11902@lists.php.net to get a copy of this message | ||
> --- Paolo Nesti Poggi <pnp@italyflash.com> wrote:
> > inside my php application it is included and registered by doing:
> >
> >
> include_once('Smarty/Smarty_nocache_cmpt/block.php_component_nc.php');//on
> > the include dir path
> > $smartyDisplay->register_block('php_component_nc',
> > 'php_component_nc',
> > false);
> >
> > Now if I run it with:
> > $this->caching=false;
> >
> > everything is all right but when
> > $this->caching=true;
> >
> > I get:
> > Fatal error: Smarty error: [in candidate/it.tpl line 29]: [plugin]
> > could not
> > load plugin file 'block.php_component_nc.php' (core.load_plugins.php,
> > line
> > 118) in /usr/share/munk_php/Smarty-2.6.6/libs/Smarty.class.php on
> > line 1088
>
> Well, the naming convention is only used for autoloaded plugins. Since
> autoloaded plugins are always cachable (there is no naming convention
> for non-cachable plugins, atm) you must register them, much like you
> are doing. The difference is that when you manually register a plugin,
> Smarty does NOT use the naming convention. Thus:
>
> $smartyDisplay->register_block('php_component_nc',
> 'smarty_block_php_component_nc', false);
>
> is the correct way to register your plugin. I suspect that since your
> registration is incorrect, Smarty is trying to autoload the plugin and
> thus your error. This should also explain why the examples in the
> manual do not follow the naming convention: they are manual
> registrations.
Yes I see.
I could make it to work now and I've understood that:
Manually registered plugins MUST NOT follow the naming convention of
automatically loaded plugins.
However they must be inside the plugins directory (most appropriately
custom_plugins) for smarty to be able to find them.
Thank you for your resolutive indication.
For the record I can say that I found the manual difficult to interpret on
this item.
The difficulty were:
1. finding out that autoloaded plugins cannot be made uncacheable
2. working on plugins I read about the naming convention. It is not said in
any point that this is only valid for autoloaded plugins. I can see the use
of it now, after having looked at the code, but the text doesn't even imply
it.
3. in the pages of the manual about register_function and register_block a
word about the difference between
manually loaded plugins and autoloaded ones, with regard to names, would
help.
Thanks again
Paolo