|
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 |
Christopher Smarty n00b
Joined: 30 May 2005 Posts: 1
|
Posted: Mon May 30, 2005 10:57 am Post subject: problem with PHP5 and class Constant |
|
|
I'm using class constant with php5 (usefull to keep the code clean).
There is a problem then trying using them inside template.
Class definition:
Code: | Class Article {
const ONLINE=0;
const OFFLINE=1;
var $etat=0;
}
|
Template:
Code: | {if $article->etat == Article::ONLINE}online{else}offline{/if}
|
Smarty don't recognise this way off using a class constante, I got the error:
syntax error: unidentified token '::ONLINE'
Then I look at the code generate, Smarty have create that:
Code: | <?php if ($this->_tpl_vars['article']->'etat == Article ::ONLINE): ?>
|
Note the 'space' before the ::
Class constant is very usefull then writing oo code. It help keeping the code clean and ease the reading of old code. Could it be possible to resolve this issue.
Is seems that the result code work beside the Smarty Error message.
Thx for the work done. I only use Smarty now, on all my project |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Mon May 30, 2005 3:41 pm Post subject: |
|
|
This is not a bug. PHP5 class constants are simply not supported in Smarty (Smarty is a PHP4 library). Furthormore, that style of constant access is not supported by Smarty either (you need to access global constants via the $smarty variable as described in the manual).
The next major release will likely address this but how and where has not been decided -- while class constants make a lot of sense for PHP5 class code, they make much less sense for a template system that is supposed to abstract application details away from the template user. |
|
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
|