Multi Site Content Provider

Posted by Community Admin on 04-Aug-2018 16:53

Multi Site Content Provider

All Replies

Posted by Community Admin on 24-Mar-2015 00:00

I have created a Calendar custom widget that uses the Events scheduled in Sitefinity. The custom Widget was designed using jQuery Full Calendar. This custom widget will be used in two different sites using a drop down list to allow user to select content site in the designer. Currently my designed only list one site, but there are two sites to pull content from, One is the Default Web Site, the other is the Sitefinity Clic Website. My code is as follows in the back end of the designer.

 

 class EventProvider
       
            public string ProviderName get; set;
            public string SiteName get; set;
       
        #region Methods
        protected override void InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container)
       
            // Place your initialization logic here
            // initialize the taxonomy selectors
            CategoriesSelector.TaxonomyId = TaxonomyManager.CategoriesTaxonomyId;
            TagsSelector.TaxonomyId = TaxonomyManager.TagsTaxonomyId;
            var multisiteContext = SystemManager.CurrentContext as MultisiteContext;
            var sites = multisiteContext.GetSites().FirstOrDefault().Name;
            var providers = GetProviders(typeof(EventsManager).FullName);
            DropDownList SiteList = (DropDownList)this.dataSourceName;
            foreach(var p in providers)
           
                SiteList.Items.Add(p.SiteName);
           
                       

        IEnumerable<EventProvider> GetProviders(string dataSourceName)
       
            var sn = SystemManager.CurrentContext.CurrentSite.SiteDataSourceLinks;
            return SystemManager.CurrentContext.CurrentSite.SiteDataSourceLinks
                .Where(o => o.DataSourceName == dataSourceName)
                .Select(o => new EventProvider
                   
                        ProviderName = o.ProviderName,
                        SiteName = ((MultisiteContext)SystemManager.CurrentContext).GetSiteById(o.SiteId).Name
                   
                );
       
        #endregion

Posted by Community Admin on 27-Mar-2015 00:00

Hi,

You can use the approach described in this post to get the providers for the different sites: http://www.sitefinity.com/developer-network/forums/developing-with-sitefinity-/multisite---accessing-content-across-sites-#RWGDut_9Okai2DWQLcll-w

Regards,
Atanas Valchev
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed