05
Apr
0
Check to see if a widget area has any widgets
If you want to check that a WidgetArea actually has widgets, and only
display it if it has, you can add this function to your Page_Controller (where widgetBarID is the name of your widgetArea + ID):
Then in your template file, MyPage.ss you can use HasWidgets to check whether the WidgetArea should be rendered:
You need to have added a WidgetArea to your page (called 'Widgetbar' in this example), otherwise the above will fail and you'll get a white page of
death. This code will add a widgetArea to MyPage:
About the Author
Name: Chris Rowbotham
Website: http://www.functionalandelegant.co.uk
Chris is a web designer / software developer based in Lancaster, England. He runs functional & elegant, a small company specialising in bespoke software, training and web design.
Comments (0)
No one has commented on this page yet.
RSS feed for comments on this page RSS feed for all comments