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.

Template Questions /

Displaying Text Based on Enum Value


Reply


2 Posts   633 Views

Avatar
DanStephenson

Community Member, 116 Posts

18 October 2011 at 5:00pm

Hello,

I am working with the Event Calendar module. Inside my DOM I've added an enum called AgeGroup which allows the user to select three options - Kids Only, Families, Adults Only

Based on the value the user selects, I want to display a different message. So for example, if the user selects "Kids Only" I want to display the message in the template - "Kids, leave your parents at home"

I've tried doing this:

<% if AgeGroup == "Kids Only" %>Kids, leave your parents at home<% end_if %>


and get this error

Parse error: syntax error, unexpected '}'

Can anyone help me correct my syntax?

Avatar
martimiz

Forum Moderator, 1132 Posts

18 October 2011 at 11:04pm

The syntax for an if-control would normally be (with a singe '=' and no quotes):

<% if AgeGroup = Kids Only %>Kids, leave your parents at home<% end_if %>

Unfortunately the templating syntax will not allow for spaces within this control, so this will still not work. You might create a function in your Page_Controler, something like:

function KidsOnly() {
   return ($this->AgeGroup == 'Kids Only');
}

then use:

<% if KidsOnly %>Kids, leave your parents at home<% end_if %>