Observations on Disabling and Renaming Toolbox Widgets
I am interested in further discussion / documentation / pointers to blog posts on this topic.
I have observed the following about configuring Toolbox Widgets*
- You can disable a widget in the toolbox config and it will remove it from the toolbox, but not from any existing pages where it was used. This appears to be a decent way to depreciate a widget from your site as it will prevent any new uses of the widget.
<!-- In ToolboxesConfig.config -->
<!-- Disabled this widget from the toolbox by setting enabled to false -->
<
add
enabled
=
"False"
type
=
"~/Custom/Foo.ascx"
title
=
"Foo"
description
=
"Displays all Foo automatically"
cssClass
=
"widFooIcn"
layoutTemplate
=
"~/Custom/Foo.ascx"
visibilityMode
=
"None"
name
=
"FooControl"
/>
<!-- In ToolboxesConfig.config -->
<!-- Updated Foo to Bar in name and title -->
<
add
enabled
=
"True"
type
=
"~/Custom/Foo.ascx"
title
=
"Bar"
description
=
"Displays all Bar automatically"
cssClass
=
"widFooIcn"
layoutTemplate
=
"~/Custom/Foo.ascx"
visibilityMode
=
"None"
name
=
"BarControl"
/>
So what I don't know at this time is:
I have observed the following while investigating whether I can replace or update a user control mapped to an existing widget:
- You CAN update an existing user control registered as a toolbar widget, both its logic and its public properties as long as it keeps the same type in the Toolbox Config. The changes will appear on existing instances of the widget in your published pages. Logic changes will go into effect immediately. Added properties will be available if you click 'edit' to view widget properties, but will use your default value or blank until you set a value in each instance. I have not tested to see if I can remove public properties, but I assume that would be problematic.
<!-- In ToolboxesConfig.config -->
<!-- Foo.ascx was updated with improved logic and public props and recompiled, but we ARE NOT changing this config file -->
<
add
enabled
=
"True"
type
=
"~/Custom/Foo.ascx"
title
=
"Foo"
description
=
"Displays all Foo automatically"
cssClass
=
"widFooIcn"
layoutTemplate
=
"~/Custom/Foo.ascx"
visibilityMode
=
"None"
name
=
"FooControl"
/>
<!-- In ToolboxesConfig.config -->
<!-- Foo.ascx was replaced with Bar.ascx, but we are keeping the same name, title -->
<!-- While this will still appear as Foo in the widget toolbar, Sitefinity will treat it as a brand new widget since the type has changed -->
<
add
enabled
=
"True"
type
=
"~/Custom/Bar.ascx"
title
=
"Foo"
description
=
"Displays all Foo automatically"
cssClass
=
"widFooIcn"
layoutTemplate
=
"~/Custom/Bar.ascx"
visibilityMode
=
"None"
name
=
"FooControl"
/>
This is not something I've tested specifically, but I thought you might find this helpful. In the SDK is a sample Sitemap module, where I needed to get all pages that had a specific control (newsview) on them. Using the Fluent API I was able to run the following Query:
var NewsPages = App.WorkWith().Pages().Where(p => p.Page !=
null
&& p.ShowInNavigation && p.Page.Controls.Where(c => c.ObjectType.StartsWith(
typeof
(NewsView).FullName)).Count() > 0).Get();
var newsView = page.Page.Controls.Where(c => c.ObjectType.StartsWith(
typeof
(NewsView).FullName)).First();
var controlDefinition = newsView.Properties.Where(p => p.Name ==
"ControlDefinition"
).FirstOrDefault();
var providerNameProperty = controlDefinition.ChildProperties.Where(p => p.Name ==
"ProviderName"
).FirstOrDefault();