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

Bug when using register_function()

 
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
cyppe
Smarty n00b


Joined: 29 Feb 2004
Posts: 2

PostPosted: Sun Feb 29, 2004 3:32 pm    Post subject: Bug when using register_function() Reply with quote

Hi!

This must be a bugg!

When I use register_function, it all works great.. so it's not that function itself that is playing with me.

Check this out:

index.php
[php:1:b0105682bf]<?php
$smarty->register_function("checkDayName", "checkDayName");
?>[/php:1:b0105682bf]---

index.tpl
----------
$menuitem[items].midate holds a date, like "2004-02-02"
---------


Code:
{checkDayName date="$menuitem[items].midate" list="Måndag,Tisdag,Onsdag,Torsdag1,Fredag,Lördag,Söndag"}


--
That does not work, this is the code it generates:

------------ cache code --------------

[php:1:b0105682bf]<?php
<?php echo checkDayName(array('date' => ($this->_tpl_vars['menuitem'][$this->_sections['items']['index']]).".midate",'list' => "Måndag,Tisdag,Onsdag,Torsdag1,Fredag,Lördag,Söndag"), $this);?>
?>[/php:1:b0105682bf]

------ end cache code --------

So, thats whats going on. When it defines the array to send as an argument to my function it makes some mistake around

Code:
-> ]]).".midate",....


(it works to change the error in the cache and re-run it, so it's clearly a parsing error from smarty..)

The thing is, that it's not getting any error msg either, just sends some false data to my function instead of the correct date.

and NOW.. check this out:

if I call my function like this instead

Code:
{checkDayName date="2004-02-02" list="Måndag,Tisdag,Onsdag,Torsdag1,Fredag,Lördag,Söndag"}


as you see, just using the date in plain text instead of my variable i passed there before it generates this (correct) code:

[php:1:b0105682bf]<?php
<?php echo $this->_tpl_vars['menuitem'][$this->_sections['items']['index']]['midate']; ?>
?>[/php:1:b0105682bf]

Please help!

Sorry if my explain-in-english skills is not too great!

Best regards,
Thomas Andersson
Back to top
View user's profile Send private message
cyppe
Smarty n00b


Joined: 29 Feb 2004
Posts: 2

PostPosted: Sun Feb 29, 2004 3:42 pm    Post subject: Reply with quote

`` around the variable did the trick though. But still..
Back to top
View user's profile Send private message
Duncan
Smarty Pro


Joined: 16 Dec 2003
Posts: 166

PostPosted: Sun Feb 29, 2004 4:09 pm    Post subject: Reply with quote

You have to add those `` due to your multi-dimensional array, as explained here: http://smarty.php.net/manual/en/language.syntax.quotes.php
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 -> Bugs All times are GMT
Page 1 of 1

 
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