More in this section
Forums / Developing with Sitefinity / Multisite - Accessing content across sites.

Multisite - Accessing content across sites.

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
3 posts, 0 answered
  1. Chris
    Chris avatar
    2 posts
    14 Oct 2013
    18 Nov 2013
    Link to this post
    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)
    06.        {
    07.                var mg = new LibrariesManager(item);
    08.                var _currentAlbums = mg.GetAlbums();
    09.                if (_currentAlbums != null)
    10.                {
    11.                   _Albums =_Albums.Concat(_currentAlbums.ToList()).ToList();
    12.                }
    13.        }
    14.        return _Albums;
  2. Pavel Benov
    Pavel Benov avatar
    341 posts
    14 Mar 2016
    21 Nov 2013
    Link to this post
    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
  3. Chris
    Chris avatar
    2 posts
    14 Oct 2013
    21 Nov 2013 in reply to Pavel Benov
    Link to this post

    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 .
3 posts, 0 answered