View previous topic :: View next topic |
Author |
Message |
gamex Smarty Rookie
Joined: 09 Oct 2009 Posts: 9
|
Posted: Fri Oct 09, 2009 5:03 pm Post subject: Problem with plugins: function is not callable |
|
|
Here is how everything is setup on my local site:
C:/wamp/www/mysite/ is my site root
In my site root, I have two directories, smarty (which has the config and template directories) and smartylib (which has the libs2, libs3, smarty_cache, smarty_plugins, and smarty_templates_c directories). libs2 are the classes for smarty 2 and libs3 are the classes for smarty 3.
I use the following to call Smarty 2 from index.php in the site root:
define("SMARTY_DIR", "c:/wamp/www/mysite/libs2/
require_once(SMARTY_DIR . 'Smarty.class.php');
$smarty = new Smarty;
$smarty->use_sub_dirs = true;
$smarty->template_dir = 'smarty/templates';
$smarty->config_dir = 'smarty/config';
$smarty->cache_dir = 'smartylib/smarty_cache';
$smarty->compile_dir = 'smartylib/smarty_templates_c';
$smarty->plugins_dir[] = 'smartylib/smarty_plugins';
With the latest version of Smarty 2, it works fine, but when I change the SMARTY_DIR to libs3, I get the following error:
Fatal error: Uncaught exception 'Exception' with message 'Syntax Error in template "smarty/templates\index.tpl" on line 29 " </div> " function "insert_"get_header"" is not callable' in C:\wamp\www\mysite\smartylib\libs3\sysplugins\internal.templatecompilerbase.php:253
If I remove the {insert name="get_header"} line from my template, everything works perfectly. This is the only plugin I am trying to use as of now. Am I doing something wrong?
FYI, I am using Smarty 3 Build 3250
Last edited by gamex on Fri Oct 09, 2009 6:37 pm; edited 1 time in total |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Oct 09, 2009 6:34 pm Post subject: |
|
|
I'm thinking {insert} tags have not been extensively tested. We'll get to this asap. |
|
Back to top |
|
gamex Smarty Rookie
Joined: 09 Oct 2009 Posts: 9
|
Posted: Fri Oct 09, 2009 6:37 pm Post subject: |
|
|
Thanks! |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Fri Oct 09, 2009 8:59 pm Post subject: |
|
|
Use single quotes at the Name attribute until this is fixed. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sun Oct 11, 2009 8:24 pm Post subject: |
|
|
The bug with double quoted strings is fixed in the SVN now |
|
Back to top |
|
gamex Smarty Rookie
Joined: 09 Oct 2009 Posts: 9
|
Posted: Mon Oct 12, 2009 1:24 pm Post subject: |
|
|
I'm still having the same issue. I updated to the latest build, and tried with double quotes, single quotes, and no quotes, and still get the same error.
Not sure if this is any help, but it is saying the error is on line 29, which is the line after the {insert} tag:
Code: | Line 26: <div id="header">
Line 27: <a href="index.htm"><img src="images/logo.jpg" id="logo" width="245" height="143" /></a>
Line 28: {insert name="get_header"}
Line 29: </div>
|
|
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Oct 12, 2009 1:51 pm Post subject: |
|
|
Did you empty your templates_c folder? Otherwise Smarty grabs the old compiled template. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Oct 12, 2009 2:03 pm Post subject: |
|
|
Do you still see: ... function "insert_"get_header"" is not callable ?
What does the error now exactly look like regarding quoutes? |
|
Back to top |
|
gamex Smarty Rookie
Joined: 09 Oct 2009 Posts: 9
|
Posted: Mon Oct 12, 2009 4:26 pm Post subject: |
|
|
Edit: Yes, I tried clearing the compiled templates. Didnt originally see that first message
This is the entire error:
I realized the function is called smarty_insert_get_header() which I thought was the naming convention. Is this only looking for insert_get_header()?
Fatal error: Uncaught exception 'Exception' with message 'Syntax Error in template "smarty\templates\index.tpl" on line 29 " </div> " function "insert_get_header" is not callable' in C:\wamp\www\mysite\smartylib\libs3\sysplugins\internal.templatecompilerbase.php:261
Stack trace:
#0 C:\wamp\www\mysite\smartylib\libs3\sysplugins\internal.compile_insert.php(52): Smarty_Internal_TemplateCompilerBase->trigger_template_error('function "inser...')
#1 [internal function]: Smarty_Internal_Compile_Insert->compile(Array, Object(Smarty_Internal_SmartyTemplateCompiler))
#2 C:\wamp\www\mysite\smartylib\libs3\sysplugins\internal.templatecompilerbase.php(214): call_user_func_array(Array, Array)
#3 [internal function]: Smarty_Internal_TemplateCompilerBase->__call('insert', Array)
#4 C:\wamp\www\mysite\smartylib\libs3\sysplugins\internal.templatecompilerbase.php(117): Smarty_Internal_SmartyTemplateCompiler->insert(Array, Object(Smarty_Internal_SmartyTemplateCompiler))
#5 C:\wamp\www\mysite\smartylib\libs3\sysplugins\internal. in C:\wamp\www\mysite\smartylib\libs3\sysplugins\internal.templatecompilerbase.php on line 261 |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Oct 12, 2009 4:58 pm Post subject: |
|
|
insert_get_header is the right naming convention (see Smarty2 documentation). Your application script must have insert_get_header defined as a function.
If it is in an external PHP file you must use also the script attribute to load the PHP file.
So how did you implement the insert_get_header function? |
|
Back to top |
|
gamex Smarty Rookie
Joined: 09 Oct 2009 Posts: 9
|
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Oct 12, 2009 5:36 pm Post subject: |
|
|
Okay, now I understand.
Sorry, the insert as plugin is not yet supported. I will look into it ASAP. |
|
Back to top |
|
gamex Smarty Rookie
Joined: 09 Oct 2009 Posts: 9
|
Posted: Mon Oct 12, 2009 5:43 pm Post subject: |
|
|
Ahhh, alright. Didn't realize there were two ways until after I posted that.
Is one method quicker or more efficient than the other? The only reason I used it as a plugin was because that was the first result I found. I am simply using it to display the shopping cart total at the top of every page. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Oct 12, 2009 5:47 pm Post subject: |
|
|
If you implementing it inside your application script is faster. A plugin must be loaded from disk each time the template gets rendered. |
|
Back to top |
|
gamex Smarty Rookie
Joined: 09 Oct 2009 Posts: 9
|
Posted: Mon Oct 12, 2009 5:58 pm Post subject: |
|
|
Thanks! |
|
Back to top |
|
|