Programmatically getting the widgets on a page
Is there a way to programmatically fetch the widgets on a particular page? I haven't been able to find anything in the Fluent API for this.
I'm looking to programmatically build a subnav based on a parent page that is a grid of widgets. Obtaining a simple list of Widgets by Page is all I need.
Thanks!
-Chris B.
You can see how to add/remove controls on a page using the Sitefinity API here. Also you can find the below code snippet in the news rotator sample control. This looks for pages containing a particular type of control:
private
PageNode targetNewsPage;
protected
PageNode TargetNewsPage
get
if
(
this
.targetNewsPage ==
null
)
this
.targetNewsPage = App.WorkWith().Pages()
.Where(p => p.Page !=
null
&&
p.Page.Controls.Where(c => c.ObjectType.StartsWith(
typeof
(NewsView).FullName)).Count() > 0)
.Get().FirstOrDefault();
//it can still be null in case there is no page with a NewsView on it
return
this
.targetNewsPage;