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

If variable is blank


Go to End


2 Posts   5960 Views

Avatar
DanStephenson

Community Member, 116 Posts

29 April 2009 at 5:38pm

Hi everyone,

I am building a site right now, that has a place for a user to enter custom content into their sidebar. This content shows up inside a custom div, with a background image.

Is there a way, inside my templates, that I can essentially say "only if this content has been entered in the CMS (field is not blank/not NULL), than show this variable, else, ignore it?"

Avatar
DanStephenson

Community Member, 116 Posts

29 April 2009 at 5:43pm

Nevermind, I figured this out. For anyone else who may need this, here is the code, assuming you're working with the variable called SidebarContent

<% if SidebarContent %>$SidebarContent<% end_if %>

Notice that the <% if SidebarContent %> does not contain a dollar sign ($), this is what was messing me up.