|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
cyppe Smarty n00b
Joined: 29 Feb 2004 Posts: 2
|
Posted: Sun Feb 29, 2004 3:32 pm Post subject: Bug when using register_function() |
|
|
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 |
|
cyppe Smarty n00b
Joined: 29 Feb 2004 Posts: 2
|
Posted: Sun Feb 29, 2004 3:42 pm Post subject: |
|
|
`` around the variable did the trick though. But still.. |
|
Back to top |
|
Duncan Smarty Pro
Joined: 16 Dec 2003 Posts: 166
|
|
Back to top |
|
|
|
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
|