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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Pass a simple string to a template

Go to End

2 Posts   1226 Views


Community Member, 7 Posts

25 May 2010 at 11:10am

How do I pass a simple string value to a template. The examples in the book suggest I should be able to add it as an element to the array passed to the customise function but nothing is being passed to the template.

For example if I add "MyString"=>"stringvalue" to the array sent to customise and then do <% if MyString == 'stringvalue' %> in my template nothing is happening as MyValue is not passed.

Any ideas as to what I am doing wrong?

I am using 2.4


Community Member, 135 Posts

25 May 2010 at 12:49pm

Test if the value comes up in the template by just calling the variable as so:


If it comes up, it works.

For the if statement, I don't think you are allowed to have quotes in there:

So your if statement should be:

<% if MyString == stringvalue %>

<% end_if %>