Search code examples
sitecoresitecore8sitecore-mvcsitecore8.1

Sitecore 8.1 MVC Areas views integration from Global project to multiple website


I am planning to integrate following Visual studio project with Sitecore instance:

Sample.SC.Global ( MVC project ) --This project contains global/common implementation which will be used in Website1/Website2 for example Global Global/Footer Header(GlobalHeader.cshtml,GlobalFooter.cshtml in Area folder structure ) and I am using Areas in this MVC project

Sample.SC.Helper ( C# class library) --This will work as helper class library

Sample.SC.Website1 ( MVC project ) --This project contains Views specific to this website and use Global Header/Footer from Sample.SC.Global project

Sample.SC.Website2 ( MVC project ) --This project contains Views specific to this website and use Global Header/Footer from Sample.SC.Global project

Queries:

1.How to reference GlobalHeader.cshtml and GlobalFooter.cshtml in Website1 so that when I browse Website Global Header/Footer must display with views specific to Website1/Website2

2.In Sitecore GlobalHeader/GlobalFooter view rendering item Path field should I have to enter the path of these files from Sample.SC.Global MVC project


Solution

  • I believe you can accomplish this without creating 3 website projects. You can achieve it with 1 web project. Since you are using Areas, you can break out each "child site" into a new area.

    For example this is what Visual Studio would look like -Sample.Website

    -

    • Global
    • Header
    • Footer

      • Areas
      • Site1
        • Controllers
        • Views
      • Site2
        • Controllers
        • Views

    In Sitecore, you would create 2 separate sites and a separate folder for your shared items. Remember that the only items that go under your Site/Home should be pages. Any other items should be in a Folder name Components or MetaData or something similar to that.