Hiding Custom Field Sections for Different Providers with Sitefinity Multisite Management

Hiding Custom Field Sections for Different Providers with Sitefinity Multisite Management

December 20, 2013 0 Comments

The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.

In a multisite management scenario all Sitefinity modules have the same custom and built-in fields for all sites because custom fields are added to a whole type (NewsItem, BlogPost, etc.) and are not unique per site.

A customization can be added to make certain fields hidden in some sites to achieve different custom and built-in fields population. In this blog post I will present a solution to this.

Here is a video which demonstrates the results of the below steps to hide custom fields for different sites.

1. Create javascipt file in your project and place the below javascript in it.

ActionStart = function () // Sitefinity LoadMethodName
    var urlParams = {};
    (function () {
        var match,
        pl = /\+/g,  // Regex for replacing addition symbol with a space
        search = /([^&=]+)=?([^&]*)/g,
        decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
        query = window.location.search.substring(1);
        while (match = search.exec(query))
            urlParams[decode(match[1])] = decode(match[2]);
    if (urlParams["provider"]) {
        if (urlParams["provider"] == 'newsProvider2') {
            $('.sfFormIn').each(function () {
                if (($.trim($(this).find('h2 a').text()) == 'CustomFieldsSection') || ($.trim($(this).find('h2 a').text()) == 'More options (URL, Comments)')) {
                    // debugger;

 2. Register this script to be executed when News items are edited:

Go to Administration->Settings->Advanced->ContentView->Controls->NewsBackend->NewsBackendEdit->Scripts and create new script. Fill in the textboxes with a relative path to the javascript file from step 1 and for Action method fill in ActionStart (it is also contained in the javascript file).

3. All custom fields are added to the CustomFieldsSection by default and to easily hide whole sections of custom fields trough the above script, make the default custom fields section collapse. Here is a screenshot on what properties to add to the existing custom fields section to make it collapse. Go to Administration->Settings->Advanced->ContentView->Controls->NewsBackend->NewsBackendEdit->Sections->CustomFieldSection.

Additional sections for hosting custom fields can be added and to move custom fields into new sections go to App_Data/Sitefinity/Configuration/NewsConfig.contentViewControls.NewsBackend.views.NewsBackendEdit.config and move different custom fields into the newly created sections.

This will make the custom fields section hidden when the provider for news used is named newsProvider2.

if (urlParams["provider"]) {
        if (urlParams["provider"] == 'newsProvider2') {
            $('.sfFormIn').each(function () {

In the multisite scenario for each site the news module gets added to a different provider. To check the provider name as shown in the video above, the provider name can be retrieved from the query string when this provider is requested.

To check the provider name I have added a provider from another site (here is a screenshot) so I can have two providers. The second provider can be removed if not needed after tests have completed for news module custom fields for this site.
The script removes a whole section named CustomFieldsSection. Use this approach to separate different fields in news module into sections and hide those fields in different providers/sites.

if (($.trim($(this).find('h2 a').text()) == 'CustomFieldsSection') || ($.trim($(this).find('h2 a').text()) == 'More options (URL, Comments)')) {
                    // debugger;

Stanislav Velikov

Stanislav Velikov is a Tech Support Engineer at Telerik. He joined the Sitefinity Support team in April 2011.

Comments are disabled in preview mode.
Latest Stories in
Your Inbox
More From Progress
5 Questions Automakers Should Ask to Improve Asset Uptime
Download Whitepaper
2018 Gartner Magic Quadrant Web Content Management (WCM)
Download Whitepaper
What Serverless Means for Enterprise Apps
Watch Webinar