Multisite - Accessing content across sites.

Posted by Community Admin on 04-Aug-2018 22:56

Multisite - Accessing content across sites.

All Replies

Posted by Community Admin on 18-Nov-2013 00:00

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()
02.      
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;
15.

Posted by Community Admin on 21-Nov-2013 00:00

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
            multisiteContext.ChangeCurrentSite(multisiteContext.GetSiteByName("MyOtherSiteName"));

I hope this helps.

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

Posted by Community Admin on 21-Nov-2013 00:00


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 .

This thread is closed