Home

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 (1)


  • I just came across your blog and reading your beautiful words. I thought I would leave my first comment but I don't know what to say except that I have
    enjoyed reading. Nice blog. I will keep visiting this blog very often.

    Posted by fm transmitter, 07/09/2010 2:45am (10 mins ago)

RSS feed for comments on this page RSS feed for all comments

Post your comment