Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Problem with plugins: function is not callable
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
gamex
Smarty Rookie


Joined: 09 Oct 2009
Posts: 9

PostPosted: Fri Oct 09, 2009 5:03 pm    Post subject: Problem with plugins: function is not callable Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Oct 09, 2009 6:34 pm    Post subject: Reply with quote

I'm thinking {insert} tags have not been extensively tested. We'll get to this asap.
Back to top
View user's profile Send private message Visit poster's website
gamex
Smarty Rookie


Joined: 09 Oct 2009
Posts: 9

PostPosted: Fri Oct 09, 2009 6:37 pm    Post subject: Reply with quote

Thanks!
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Fri Oct 09, 2009 8:59 pm    Post subject: Reply with quote

Use single quotes at the Name attribute until this is fixed.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sun Oct 11, 2009 8:24 pm    Post subject: Reply with quote

The bug with double quoted strings is fixed in the SVN now
Back to top
View user's profile Send private message
gamex
Smarty Rookie


Joined: 09 Oct 2009
Posts: 9

PostPosted: Mon Oct 12, 2009 1:24 pm    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Oct 12, 2009 1:51 pm    Post subject: Reply with quote

Did you empty your templates_c folder? Otherwise Smarty grabs the old compiled template.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Oct 12, 2009 2:03 pm    Post subject: Reply with quote

Do you still see: ... function "insert_"get_header"" is not callable ?

What does the error now exactly look like regarding quoutes?
Back to top
View user's profile Send private message
gamex
Smarty Rookie


Joined: 09 Oct 2009
Posts: 9

PostPosted: Mon Oct 12, 2009 4:26 pm    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Oct 12, 2009 4:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
gamex
Smarty Rookie


Joined: 09 Oct 2009
Posts: 9

PostPosted: Mon Oct 12, 2009 5:17 pm    Post subject: Reply with quote

I implemented it like it says here: http://www.smarty.net/manual/en/plugins.inserts.php

I had a php file named insert.get_header.php in the plugins directory, and named the function smarty_insert_get_header()

I am somewhat new to Smarty, and just started using it a few months ago. When looking up {insert}, that first link was the one I found, but now I see this one: http://www.smarty.net/manual/en/language.function.insert.php which seems to work a little differently
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Oct 12, 2009 5:36 pm    Post subject: Reply with quote

Okay, now I understand.

Sorry, the insert as plugin is not yet supported. I will look into it ASAP.
Back to top
View user's profile Send private message
gamex
Smarty Rookie


Joined: 09 Oct 2009
Posts: 9

PostPosted: Mon Oct 12, 2009 5:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Oct 12, 2009 5:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
gamex
Smarty Rookie


Joined: 09 Oct 2009
Posts: 9

PostPosted: Mon Oct 12, 2009 5:58 pm    Post subject: Reply with quote

Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3 All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP