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 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.

Themes /

Discuss SilverStripe Themes.

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

How do I get rid of empty SidebarHTML?

Go to End

4 Posts   1836 Views


Community Member, 216 Posts

21 August 2014 at 1:21pm

Edited: 21/08/2014 1:22pm

Right: I've got a editable field called SidebarHTML in my template. It allows Site Editors to click on a 'Sidebar' tab in the CMS and enter field that is then displayed on the page. Even I can see it's not rocket science! But how do I get rid of the field/background if there is NO content (nothing, nada, none) in the SidebarHTML field?

I'm assuming it's something like:

<% if ???? %>
<% end_if %>

Just wondering what to call ????? Any ideas?


Community Member, 67 Posts

21 August 2014 at 4:42pm

Should just be

<% if SideBarHTML %>
<% end_if %>

or maybe

<% if SideBarHTML != '' %>
<% end_if %>


Community Member, 216 Posts

21 August 2014 at 4:50pm

Edited: 21/08/2014 4:50pm

Thanks Kirk - had already tried Version 1 which didn't work, didn't know about Version 2 but unfortunately it didn't work either...


Forum Moderator, 1391 Posts

28 August 2014 at 7:00am

$SidebarHTML is just the content of the textField? So there's some HTML around that in your template that constructs the sidebar? That should be withinin the <% if %> conditional as well. But you probably did that... Also it wouldn't work if the htmltext contained only tags and/or spaces instead of visible text for some reason...