Multisite - Accessing content across sites. - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Multisite - Accessing content across sites.

  • Multisite - Accessing content across sites.
  • I am working on making our controls compatible with multisite.  Right now I have not found a good generic solution for getting all content of a particular type accessible to a site.  At the moment this is a rough example of what I have for finding albums, but I would like to know if there is a better way than iterating through each provider and and checking permissions for each site.  What I am looking for is the most generic solution for finding content that a site can access. 

    01.public IList<Album> getAlbumns()
    03.         IList<string> _ProvidersNames = LibrariesManager.ProvidersCollection.Select(item => item.Name);
    04.        IList<Album> _Albums = new List<Album>();
    05.        foreach (var item in _ProvidersNames)
    07.                var mg = new LibrariesManager(item);
    08.                var _currentAlbums = mg.GetAlbums();
    09.                if (_currentAlbums != null)
    11.                   _Albums =_Albums.Concat(_currentAlbums.ToList()).ToList();
    14.        return _Albums;
  • Hello Chris,

    We currently do not expose API for getting all items from a module regardless of site's context. The way to get all items is to get the providers for this module and iterate through them (which you have already done). You can also use the following API queries to change site context, get providers, etc.:

    var multisiteContext = SystemManager.CurrentContext as MultisiteContext;
                ///get the current site by name
                var currentSiteName = multisiteContext.CurrentSite.Name;
                //get the module's provider by the module's name
                var currentSiteProv = multisiteContext.CurrentSite.GetProviders("ModuleName").Select(p => p.ProviderName);
                //if you need to change the site context

    I hope this helps.

    Pavel Benov
    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 Public Issue Tracking system and vote to affect the priority of the items

  • First,  thank you for your response.  That will be helpful in transitioning some of our code!

    Secondly I have a question about the context of this statement below.

    var __providers = multisiteContext.CurrentSite.GetProviders(ModuleName);

    In the above line of code would __providers will be all providers for the module that the site owns or has permission to use.  If I need to do more to check permission how do I check Permission for those providers in a generic way (meaning using this in a helper library where the user-context isn't known until runtime .