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.

Widgets /

Discuss SilverStripe Widgets.

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

Widget in template / isEmpty [solved]


Go to End


2 Posts   1754 Views

Avatar
rob.s

Community Member, 78 Posts

13 January 2011 at 11:27pm

Edited: 13/01/2011 11:27pm

Hi,

how do i recognize if widget area is empty ?
I need this inside the template

The name of my widgetArea is 'SideBlock'

The following template code does NOT work for me.
(guessing the method SideBlock() only returns false/null when the relation does not exist)

<% if SideBlock %>
   <div class="span-18">
<% else %>
   <div class="span-24 last">
<% end_if %>

Any ideas ?

Grettings,
Rob

Avatar
rob.s

Community Member, 78 Posts

19 January 2011 at 9:56pm

Solution:


<% if SideBlock.Widgets %>
<div class="span-18">
<% else %>
<div class="span-24 last">
<% end_if %>