+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Multi Site Content Provider

Multi Site Content Provider

2 posts, 0 answered
  1. Mauro
    Mauro avatar
    4 posts
    Registered:
    10 Mar 2014
    24 Mar 2015
    Link to this post

    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

  2. Atanas Valchev
    Atanas Valchev avatar
    414 posts
    Registered:
    04 Jan 2016
    27 Mar 2015
    Link to this post
    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
     
2 posts, 0 answered