Workaround: Using the Sitefinity TaxonomyControl with Custom Modules

The Sitefinity classification widgets allow you display a list of taxonomy items (Categories, Tags, etc.) from your various content items. By default this control collects and renders all used taxonomy items, regardless of type.

There is also a ContentType property that allows you to filter the taxonomy list to only render if items of that type are linked with an associated taxonomy, allowing you to create different lists for different types.

Unfortunately, this control doesn't appear to yet support filtering of Dynamic Content Types created by the Sitefinity Module Builder. Because these are dynamic types, the control cannot bind to them, and you'll get an error similar to this:

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0234: The type or namespace name 'MyCustomType' does not exist in the namespace 'Telerik.Sitefinity.DynamicTypes.Model' (are you missing an assembly reference?)

This is a known issue in Sitefinity and will be fixed in a future release.

However, in the meantime, I created a simple workaround by creating a control that inherits from the built-in TaxonomyControl, that initializes the dynamic type and assigns it to the ContentType property. Simply create the following class:

https://gist.github.com/2378561

Then add this control to the toolbox. For ControlType, instead of the path to the control, enter the full class name including namespace.

You'll now be able to drag the control onto the page and set the DynamicModuleType to the Module type of your module (For example: Telerik.Sitefinity.DynamicTypes.Model.Showcases.Showcase) and the taxonomy control will now only show items of that type.

Hope this is helpful!

Enjoyed this post and/or found it useful?
Tagged with:
SelArom Dot Net Profile Image
SelAromDotNet

Josh loves all things Microsoft and Windows, and develops solutions for Web, Desktop and Mobile using the .NET Framework, Azure, UWP and everything else in the Microsoft Stack.

His other passion is music, and in his spare time Josh spins and produces electronic music under the name DJ SelArom.



Scroll to top