November Happy Hour will be moved to Thursday December 5th.

Multisite and share pages

Vote:
 

Hi

I am currently developing a Episerver (version 8.8.0) multisite solution (many markets /languages).

This is what the editors want.

  • Want some parts of page tree to be the same in all sites (news and child pages is one example). They also want to publish content from any of the sites.

I have read about content providers and seen the cloned content provider in alloy templates. Is this the way to go and does anybody have some code to share on this or a link to Github/nuget?

Cheers.

Regards Øyvind

#123579
Jul 09, 2015 7:39
Vote:
 

I have now tested the cloned content provider. It works ok. But i want all capabilities enabled.

cloned content provider just have Search capabilities.

public override ContentProviderCapabilities ProviderCapabilities { get { return ContentProviderCapabilities.Search; } }

This is what i want

        public override ContentProviderCapabilities ProviderCapabilities
        {
            get
            {
                return ContentProviderCapabilities.Search | ContentProviderCapabilities.MultiLanguage | ContentProviderCapabilities.Create | ContentProviderCapabilities.Edit | ContentProviderCapabilities.Copy | ContentProviderCapabilities.Delete | ContentProviderCapabilities.Security | ContentProviderCapabilities.Wastebasket;
            }
        }

Does anybody have a provider code that is working to share ?

Regards Øyvind

#123710
Jul 16, 2015 14:15
Vote:
 

Hi,

I was using similar functionality in one of the project (some tree nodes was displayd several times and shared). There was no problems with this functionality.

I think that you should simply follow the documentation for Configuring content providers. There is also working example based on XML content provider here.

#123714
Jul 16, 2015 23:32
Vote:
 

Hi,

I was sure this should be easy to, but just cant get it to work. I have read both your link,. I am missing something important. I made an easy example, can you show me some code that works.

I found a DefaultContentProvider and i have read here that this is the one that episerver uses, can i use it?. Right now i am inherit from ContentProvider

I want to display threenode 44 under emty threenode 164 as an example.

Added this to web.config and also created a MyContentProviderInitialization.cs

  <episerver>
      <contentProvider>
      <providers>
        <add name="MyContentProvider"
                type="EpiserverDemoSite.Business.ContentProviders.MyContentProvider, EpiserverDemoSite"
                entryPoint="164"
                capabilities="Create,Edit,Delete,Search,Wastebasket,MultiLanguage,Copy"/>
      </providers>
    </contentProvider>    
    
  </episerver>
using System;
using System.Configuration;
using System.Linq;
using EpiserverDemoSite.Business.ContentProviders;
using EpiserverDemoSite.Models.Pages;
using EPiServer;
using EPiServer.Core;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.Logging;
using EPiServer.ServiceLocation;
using EPiServer.Web;

namespace EpiserverDemoSite.Business.Initialization
{
    [ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
    public class MyContentProviderInitialization : IInitializableModule
    {
        private static readonly ILogger Logger = LogManager.GetLogger();

        private bool _initialized;

        public void Initialize(InitializationEngine context)
        {
            if (_initialized || context.HostType != HostType.WebApplication)
            {
                return;
            }

            var providerManager = ServiceLocator.Current.GetInstance<IContentProviderManager>();
            //I can see my contentprovider in providerManager
            var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();


            var myContentprovider = new MyContentProvider();
            //providerManager.ProviderMap.AddProvider(myContentprovider);  //When it is in config i cant add it here
            

            _initialized = true;
        }




        public void Preload(string[] parameters) { }

        public void Uninitialize(InitializationEngine context) { }
    }
}

MyContentProvider.cs

using EPiServer;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.ServiceLocation;
using EPiServer.Web;
using EpiserverDemoSite.Models.Pages;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace EpiserverDemoSite.Business.ContentProviders
{
    public class MyContentProvider : ContentProvider
    {
        public override ContentProviderCapabilities ProviderCapabilities
        {
            //In Debug this code runs
            //Guess this is not needed when it is in config also
            get { return ContentProviderCapabilities.Edit | ContentProviderCapabilities.Move | ContentProviderCapabilities.MultiLanguage | ContentProviderCapabilities.Create; }
        }

        protected override IContent LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
        {
            // This newer happens
            throw new NotImplementedException();
        }

        /// <summary>
        /// Content that i want to share where do i set this
        /// </summary>
        public ContentReference SharedContentRefence { 
            get { return new ContentReference(44);} 
        }

        protected virtual ContentStore ContentStore
        {
            get { return ServiceLocator.Current.GetInstance<ContentStore>(); }
        }

        protected virtual IContentLoader ContentLoader
        {
            get { return ServiceLocator.Current.GetInstance<IContentLoader>(); }
        }
    }
}
#123724
Jul 17, 2015 10:02
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.