Filter by data provider the items displayed on backend pages
When you have more than one provider for a module, you can choose which items to display in the backend pages of the module. You can do this by using QueryString parameters. When you select a provider, different than the default, a query string is added to the URL – for example, ../?provider=Testprovider.
To display items from a specific provider, perform the following:
- Create a widget that uses the following code:
C#
using System; using System.Web; namespace SitefinityWebApp { public partial class TestWidget : System.Web.UI.UserControl { public string DefaultProvider { get; set; } protected void Page_Load(object sender, EventArgs e) { if (DefaultProvider.IsNullOrWhitespace()) { //you can set default value here if not filled from the widget designer //DefaultProvider = ""; } else { var url = HttpContext.Current.Request.Url; if (!url.Query.ToString().Contains(DefaultProvider)) { Response.Redirect(url + "?provider=" + DefaultProvider); } } } } } - Register the widget in the toolbox, using procedure Register a new widget in Sitefinity CMS toolbox.
- Click Administration» Backend pages and open for editing the pages where you want to filter the items displayed.
For example, if you have a module, called MyModule, which has two data providers – Defaultand MyProvider, you can choose to display in the grid only items from MyProvider. Open for editing the backend page for MyModule. - Drop the newly registered widget anywhere on the page and click its Editbutton.
- In DefaultProviderfield, enter the data provider whose items you want to display.
It can be the Defualt(OpenAccessProvider) or any other you have created. - Click Save.
The widget appends the selected provider as a QueryString to the page. - Hide the other providers from the backend page using CSS.
Perform the following:- Drag the CSS widget anywhere on the page and click its Editbutton.
- For example, if you want the page to display the second provider and hide the other two, in the CSS widget, enter the following:
CSS
#providerListItem0, #providerListItem2 { display: none;}
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
Get started with Integration Hub | Sitefinity Cloud
This free lesson teaches administrators, marketers, and other business professionals how to use Sitefinity Integration Hub to create automated workflows between Sitefinity and other business systems.
Web Security for Sitefinity Administrators
This free lesson teaches administrators the basics about protecting your Sitefinity instance and your sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
Foundations of Sitefinity ASP.NET Core Development
The free on-demand video course teaches developers how to use Sitefinity ASP.NET Core and take advantage of its decoupled architecture and modern development model.