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

Can't use variable modifiers
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 -> Bugs
View previous topic :: View next topic  
Author Message
daan.timmer
Smarty Rookie


Joined: 10 Feb 2009
Posts: 9

PostPosted: Tue Feb 10, 2009 11:22 am    Post subject: Can't use variable modifiers Reply with quote

For somereason I cannot use any variable modifiers.
When I do something like: {$foo|escape} I get this error message:
Code:
Fatal error: Smarty error: [in zoeken.html line 59]: [plugin] modifier '|escape' is not implemented (core.load_plugins.php, line 118) in /home/m5nnl/public_html/Smarty.class.php on line 1002

Although I am 100% sure it is enabled/in the plugins folder

However, when I use this: {$foo|escape:'htmlall'} I get the following:
Code:
Parse error: syntax error, unexpected T_STRING, expecting ')' in /home/m5nnl/public_html/templates_c/%%60^602^602F2794%%zoeken.html.php on line 4
Generated PHP Code:
Code:
smarty_core_load_plugins(array('plugins' => array(array('modifier', '|escape:'htmlall'', 'zoeken.html', 59, false),)), $this); ?>
When I change the single to double quote I will get:
Code:
Parse error: syntax error, unexpected ':' in /home/m5nnl/public_html/templates_c/%%60^602^602F2794%%zoeken.html.php on line 88
And generated PHP:
Code:
<a href="<?php echo ((is_array($_tmp=$this->_tpl_vars['resultaatje']->column1)) ? $this->_run_mod_handler('|escape:"htmlall"', true, $_tmp) : smarty_modifier_|escape:"htmlall"($_tmp)); ?>


I havent changed anything with how smarty works or handles. I used to be able to do this on an other server but this server doesnt like it it seams >_<

Any clue on how to fix this?
Back to top
View user's profile Send private message
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 321

PostPosted: Tue Feb 10, 2009 2:23 pm    Post subject: Re: Can't use variable modifiers Reply with quote

daan.timmer wrote:
For somereason I cannot use any variable modifiers.
When I do something like: {$foo|escape} I get this error message:
Code:
Fatal error: Smarty error: [in zoeken.html line 59]: [plugin] modifier '|escape' is not implemented (core.load_plugins.php, line 118) in /home/m5nnl/public_html/Smarty.class.php on line 1002

Although I am 100% sure it is enabled/in the plugins folder


You can find the correct use of escape here

http://www.smarty.net/manual/en/language.modifier.escape.php

The error message says escape modifier is not available.

Are you sure the file modifier.escape.php is valid? Some ftp programs make files corrupt on uploading.

Does other modifiers work? Is the path to plugins folder correct?
Back to top
View user's profile Send private message
daan.timmer
Smarty Rookie


Joined: 10 Feb 2009
Posts: 9

PostPosted: Tue Feb 10, 2009 5:02 pm    Post subject: Reply with quote

No other modifiers work. I tried registering my own modifier, doesn't work either.

For some reason smarty is compiling incorrectly. It is creating a function call like this:

smarty_modifier_|escape:"htmlall"($_tmp);

However, it should compile to:
smarty_modifier_escape($_tmp,"htmlall");

(Atleast, what I can remember top of my head)
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Tue Feb 10, 2009 5:06 pm    Post subject: Reply with quote

Check your plugins_dir setting, be certain it points to the plugin directory. You can test it by trying to read the file directly in PHP:

Code:
readfile($smarty->plugins_dir.'/modifier.escape.php');


If you get an error, something isn't setup right.
Back to top
View user's profile Send private message Visit poster's website
daan.timmer
Smarty Rookie


Joined: 10 Feb 2009
Posts: 9

PostPosted: Tue Feb 10, 2009 5:25 pm    Post subject: Reply with quote

That works like a charm...
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Tue Feb 10, 2009 8:56 pm    Post subject: Reply with quote

You don't have something like magic_quotes enabled do you? Is the compile_dir writable? Is all of Smarty and its lib dirs installed correctly? Are there any php errors or web server errors that may help?
Back to top
View user's profile Send private message Visit poster's website
daan.timmer
Smarty Rookie


Joined: 10 Feb 2009
Posts: 9

PostPosted: Wed Feb 11, 2009 12:29 am    Post subject: Reply with quote

To answer your question about the magic_quotes:
Code:

magic_quotes_gpc   On   On
magic_quotes_runtime   Off   Off
magic_quotes_sybase   Off   Off


compile?dir is writable. All Smarty libs are installed and no PHP errors (That is I have error_reporting set to E_ALL)

No webserver errors.

If I don't use any variable modifier everything goes fine. But as soon as I want to use a modifier the compile somehow fails.

No matter what modifier that is btw.

*Function s do work btw (like {CYCLE})

Also, character encoding is set to LATIN-1 (ISO-8859-1)
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Wed Feb 11, 2009 1:06 am    Post subject: Reply with quote

Turn magic_quotes_gpc off.
Back to top
View user's profile Send private message Visit poster's website
daan.timmer
Smarty Rookie


Joined: 10 Feb 2009
Posts: 9

PostPosted: Wed Feb 11, 2009 9:36 am    Post subject: Reply with quote

They are turned off now. Still the same problem

Code:
Fatal error: Smarty error: [in header.html line 48]: [plugin] modifier '|escape' is not implemented (core.load_plugins.php, line 118) in /home/m5nnl/public_html/Smarty.class.php on line 1002


[edit1]
{$current_index|escape}

[edit2]
Also, if any help: I(the server) am using PHP 5.2.6

[edit3]
It seems as if the compiler doesnt 'strip' the pipe-char from the string resulting in saying it can't find |modifier

[edit4]
Another problem that I have is this: when I use {literal}{/literal} Everything between the tags will be stripped from the file.

So this:
Code:
<script type="text/javascript">
{literal}
function someJSFunction(){}
{/literal}
</script>


Will result in:
Code:
<script type="text/javascript">

</script>
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Wed Feb 11, 2009 3:06 pm    Post subject: Reply with quote

There is definitely something strange here. Have you tried unpacking a vanilla install of Smarty and do a very simple test against the install?
Back to top
View user's profile Send private message Visit poster's website
daan.timmer
Smarty Rookie


Joined: 10 Feb 2009
Posts: 9

PostPosted: Wed Feb 11, 2009 3:46 pm    Post subject: Reply with quote

It is a fresh install.

I can try a downgrade.

[edit]
Did a fresh downgrade to 2.6.19 Same problem
Back to top
View user's profile Send private message
streetlogics
Smarty n00b


Joined: 03 Mar 2009
Posts: 3

PostPosted: Tue Mar 03, 2009 10:58 pm    Post subject: Reply with quote

We are having the same issue here - we keep getting the error saying

Quote:
"Fatal error: Smarty error: [in view_event_media.tpl line 134]: [plugin] modifier '|strtoupper' is not implemented (core.load_plugins.php, line 118)".


As I understand it, all PHP functions should be implemented.

Digging through the code, in core.load_plugins.php on line 99, this is where the message is being set, and it's being set from the call:
Code:

if (! function_exists ( $_name )) {
     $_message = "modifier '$_name' is not implemented";
}


Going through this logically, if I enter a PHP function name, it should ALWAYS return true for function_exists - since this is not the case, I believe the problem to be as stated by the previous member that it's looking for a function named "|strtolower" instead of the correct "strtolower" (no pipe).

I tried adding a quick "$_name = str_replace("|","",$_name);", but this just caused weird stuff to happen and didn't actually force the function to execute. This is getting so frustrating - all I want to do is use some PHP functions that the SMARTY docs say should work.
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Tue Mar 03, 2009 11:12 pm    Post subject: Reply with quote

Does a vanilla install of Smarty work with a simple test case? Just {$foo|escape} in a template?
Back to top
View user's profile Send private message Visit poster's website
daan.timmer
Smarty Rookie


Joined: 10 Feb 2009
Posts: 9

PostPosted: Tue Mar 03, 2009 11:26 pm    Post subject: Reply with quote

Nopes, at least, it didnt on my server. How ever on the exact same server, different domain, everything DOES work.

I compared (using a real compare tool) the two phpinfo()'s and they are identical (except for domain names)

So I guess it is something server related, but what? IDK. Both servers are also set-up in the same way. I just copy-pasted the whole project from one domain to the other and on that one it did work... On the other it stilld oesnt...
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Tue Mar 03, 2009 11:27 pm    Post subject: Reply with quote

Did you compare the compiled templates between the two platforms? Are the PHP versions the same? Is magic quotes enabled in any way?

OS and PHP versions?


Last edited by mohrt on Tue Mar 03, 2009 11:29 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
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 -> Bugs 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