Deliver superior customer experiences with an AI-driven platform for creating and deploying cognitive chatbots
Deliver Awesome UI with the most complete toolboxes for .NET, Web and Mobile development
Automate UI, load and performance testing for web, desktop and mobile
A complete cloud platform for an app or your entire digital business
Detect and predict anomalies by automating machine learning to achieve higher asset uptime and maximized yield
Automate decision processes with a no-code business rules engine
Optimize data integration with high-performance connectivity
Connect to any cloud or on-premises data source using a standard interface
Build engaging multi-channel web and digital experiences with intuitive web content management
Personalize and optimize the customer experience across digital touchpoints
Build, protect and deploy apps across any platform and mobile device
Rapidly develop, manage and deploy business apps, delivered as SaaS in the cloud
If you ever wanted to relate Sitefinity users to one of your Dynamic Content Modules, you probably noticed that there is not an easy, out-of-the-box way to do that. Luckily, Sitefinity is designed for extensibility from the ground up so this relation is quite easy to achieve. This blog post will detail how you can do that in few simple steps. For your convenience, the source code needed for this feature is already implemented, and the only thing left to do is integrate it into your Sitefinity application. The solution is based on a field control that lets you select one or many user which are going to be related to your dynamic content items. On the dynamic content side, the users are stored as an array of user identifiers (Guid). Both of these functionalities, the custom field control and the array of GUIDs field, have been supported by Sitefinity for a long time. We are now just using their power to create a useful feature which many of you have been asking for or trying to do.
I am not going to explain the implementation of the RelatedUsers field control, because that is not the purpose of this post, but I will just explain how to integrate it to your Dynamic Content Module. You can find the source of the field control in this GitHub repository.
For the sake of a simple example I would assume that your web application has the default name – SitefinityWebApp, and that you use the same folder structure as in the sample: ~/FieldControls/RelatedUsers. If the conditions above are fulfilled, the CLR type of the field control should be: SitefinityWebApp.FieldControls.RelatedUsers.RelatedUsersField
Now build your solution, run the Sitefinity application and go to the Module Builder screen. There you can either create a new Dynamic module or you can edit ones that you already have. Then add a new field, give it a name by your preference and a type Array of GUIDs. Uncheck the This is a hidden field checkbox and enter the CLR type of the RelatedUsers field control in the Type or Virtual path of the custom widget input field: SitefinityWebApp.FieldControls.RelatedUsers.RelatedUsersField. The following screenshot shows the final setup of the field:
Now if you go to your content module and add/edit an item, you will see the RelatedUsers field.
If the current behavior of the user selector does not fit your needs, you can additionally tweak a lot of it. The user selector is based on the Sitefinity FlatSelector, which means that all of the FlatSelector options can be changed. The easiest way to do this is through the template file of the user selector field (RelatedUsersField.ascx), by changing the attributes of the FlatSelector control. Popular tweaks for this control are: AllowPaging, PageSize, AllowMultipleSelection, AllowSearching, ShowProvidersList, etc. See the following screenshot of the current configuration:
Moreover, you can go crazy and further develop some additional functionality which you might need, because you have all of the source code of this selector.
View all posts from Ivan Eftimov on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Copyright © 2018 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.