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.

Themes

Discuss SilverStripe Themes.

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

How do I get rid of empty SidebarHTML?


Reply

4 Posts   198 Views

Avatar
arthurdent

21 August 2014 at 1:21pm (Last edited: 21 August 2014 1:22pm), Community Member, 166 Posts

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 ???? %>
$SidebarHTML
<% end_if %>

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

Avatar
Kirk

21 August 2014 at 4:42pm Community Member, 42 Posts

Should just be

<% if SideBarHTML %>
$SidebarHTML
<% end_if %>

or maybe

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

Avatar
arthurdent

21 August 2014 at 4:50pm (Last edited: 21 August 2014 4:50pm), Community Member, 166 Posts

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

Avatar
martimiz

28 August 2014 at 7:00am Forum Moderator, 1091 Posts

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