Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Boolean and null values in templates


Go to End


1246 Views

Avatar
Jare

Community Member, 39 Posts

27 July 2016 at 6:49am

Hi,

what would be the best way to use boolean and null values in method calls inside templates? See:

MyTemplate.ss:

<html>
<body>
Some HTML.
$MyMethod(false)
$AnotherMethod(true)
$ThirdMethod(null)
</body>
</html>

Currently what happens with those examples is that words false, true and null are converted to strings, which obey to the old, deprecated template syntax that allowed us to write strings without wrapping them to quotes.

Is it possible at all, or should I just use 1 to indicate true and 0 to indicate false/null? I really would like to use strict data types inside my PHP class methods.

Thank you for your help! :)