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   261 Views

Avatar
arthurdent

Community Member, 170 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 ???? %>
$SidebarHTML
<% end_if %>

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

Avatar
Kirk

Community Member, 43 Posts

21 August 2014 at 4:42pm

Should just be

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

or maybe

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

Avatar
arthurdent

Community Member, 170 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...

Avatar
martimiz

Forum Moderator, 1106 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...