Setting up a Sitecore project works with both versions 5.3 and 6

Sitecore(SC) has a decent article on how to set up a Sitecore project on Visual Studio. This is a pretty good start but it does not quite meet our company’s requirements.

In this blog post I will attempt to tell you exactly how a structure a project assuming that you have the following requirements for your SC environment:

  • You need to have multiple websites running on one instance of SC and you want each website to have its own Visual Studio project.
  • You are not using a virtual folder per website.
  • You want to manage multiple Class Library/Child projects within each website project.
  • You want to keep the Renderings, Sub-layouts, Layouts, Associated files (css, js etc) and DLL’s of each website independent.

Our company has worked with multiple projects in Sitecore v5.3 and we have also Started a new project using Sitecore v6 (Visual Studio 2005 and 2008). I can safely say that we have come up with a tried and proven project structure that I can recommend that everyone can and should use. Please follow the SC developer cookbook if you are only going to ever have one website running on your instance of SC.

There is a fair bit to write on this entry and I will be slowly updating it, if anyone is in desperate need to this information right now then please leave a comment and I will try to speed things up!

HTML File Structure

It is always good to have a well structured website. Our team deals with the integration of HTML front end with SC. For this reason we usually get out HTML, CSS and JS delivered to us from a 3′rd party vendor. We get them to deliver the HTML to us in the following structure so that it fits snugly in with our intended .NET project structure:

Our website will be called “destinations“. Our main HTML files are on the highest level and we have folder named ‘destinations’ which contains all the css, images, JS etc. (the HTML will reference these files like this <img src=”/destinations/img/image1.jpg”/> )

Obviously the HTML is just your reference, we will be splitting up all the HTML into Layouts, Sublayouts and Renderings. Only the ‘destinations’ folder and its contents will actually be part of our Visual Studio project.

Had a Discussion with Elliot who posted comment on this topic. I have pasted the discussion we have had below (read from bottom up):

HI Eliot,

Sounds like a good approach, we did think of doing it the way you did but we decided not to go ahead with is simply because the Cookbook suggests that all websites are created and run via the website folder.

Even when you do my method, you should only be having the newly created web app in your VS project. You should not need to import any sitecore objects (it should effectively have been the same as your independent virtual directory arrangement). I.e. as mentioned, each website does have its own web.app even tho they have all been moved into the sitecore/websites folder.

I am assuming sitecore’s web.config will be the failover web.config is your local web.app does not contain any web.config entries that have been tweaked for that site?

Are your URL’s looking consistent when viewing a web page in preview mode now that you have created the Virtual Folders?
I can’t really think of any potential issues with your configuration at the moment and if you do manage to avoid any problems this may well be the best soloution structure yet.

Keep me informed.
Thanks,
Richard

On Fri, Jan 16, 2009 at 5:12 AM, Elliot Ritchie wrote:
Hi Richard

After experimenting with a ton of different configurations I think I’ve found the ideal way to integrate Sitecore with the current processes and project structures I’m working with right now; you’re directions definately provided a leap in the right direction!

Essentially,

  • Each website sits within its own web application that contains all the necessary css, images, renderings and layouts etc for the specific website.
  • The web applications then reference the Sitecore assemblies from a single predetermined Sitecore installation directory (this also allows for a much more efficient use of source control systems as it means each version controlled website doesn’t have to also include 300mb+ worth of Sitecore modules).
  • The web applications’ Web.config contain the necessary Sitecore configuation sections, tweaked for the specific website.
  • In IIS each web application is setup as its own website, with a virtual directory setup in each to provide the reference to the ‘/sitecore/’ directory, again this virtual directory points to the same predetermined Sitecore installation directory as before.

If you can see any holes in this setup please let me know, or any thoughts in general, but so far everything is running great!

Many Thanks

Elliot


Date: Wed, 14 Jan 2009 10:15:07 +0530
Subject: Sitecore Project structure
From: Me
To: Elliot

Hi Elliot,

I can’t really update my Blog at the moment because I am on holiday ( I will be working purely off memory). I have been pretty lazy with that I must admit.
Will try to outline the steps here (I will assume your project is called destinations following from my HTML structure blog post:

  1. You will need to follow the Sitecore developer cook book and create a project as described there (name the project DestinationsApp for consistency) within the sitecore/websites folder.
  2. Given that you will be working with multiple projects (websites) then you will need to have more than one ‘properties’ folder (one is needed for each project solution) so you will need to rename the Properties folder to something like DestinationsProperties.Once you have done this you will need to edit the DestinationsApp project (.csj I think) file with a text editor and replace all instances of the ‘properties’ folder name to match your new ‘DestinationsProperties’ folder name. Close this file and you are ready to open the project – go ahead and add a reference to Sitecore.Kernal.dll and dont forget to set copyLocal to false.
  3. Now that you have a basic Web App project there you can start adding the extra sections to this project. Create a folder within sitecore/website named ‘destinations’. Include this newly created folder in your DestinationsApp project because this will contain all the misc web files. Copy all the files from your HTML/destinations folder into the sitecore/website/destinations folder.
  4. Within the sitecore/websites/layouts folder create a folder called ‘destinations’. Include this folder in the DestinationsApp project. All your layouts and sublayouts for the destinations website should be created here within the sitecore/websites/layouts/destinations folder. You can reference your css files and image files (that will be in the folder created at step 3) from all layouts and renderings by refering to the src/link like this: <img src=\destinations\img\image1.jpg />
  5. Within the sitecore/websites/xsl folder create a folder called ‘destinations’. Include this folder in the DestinationsApp project. All your renderings for the destinations website should be created here within the sitecore/websites/xsl/destinations folder.
  6. Now you should be ready to go with the creation of a basic website. I suggest that in your Content tree you start off your content within sitecore/content/destinations/home where Home will be your home page. When you have a second website to go in your sitecore instance then that can be located within sitecore/content/secondwebsite/home in the content tree. You will ofcourse need to change the web.config <sites> section to add each website.
  7. We often have accompanying DLL class libraries (e.d. a DestinationsLogic class library project) and also a Database project when integrating 3′rd party DB’s with your sitecore website. I highly reccomend that you create and store these projects outside of your ’sitecore/website’ folder because the goal is to keep the sitecore/website folder a clutter-free as possible. Create a filder within the C drive called c:/DestinationsProjects and then create two seperate folders in here for DestinationsLogic and DestinationsDB. Add your extra projects in here and by all means create these projects by ‘adding new project’ to your DestinationsApp project solution. This way all your projects will be logically in the same Visual Studio solution but Physically seperate. Add a Reference to each of these projects in your DestinationsApp project (and leave copyLocal as true) so that each time you compile your solution a DestinationsLogic.dll will be created in the sitecore/website/bin folder.
  8. When you have this structure set up, you can easily add more websites to your sitecore instance by following steps 1 to 8 for each new websites and just replacing the word ‘Destinations’ with the name of your new website and they will all co-exsist without problems and you will end up with a highly maintainable, clutter-free project/site structure.

Hope this helps,
Richard

15 Responses to “Setting up a Sitecore project works with both versions 5.3 and 6”

  1. El Says:

    Hi Richard

    If you don’t have the time to write this up ‘officially’ would you mind dropping me an email describing the basic structure of your solutions? It would really be a huge help. The requirements you’ve listed are also my exact requirements.

    Many Thanks

  2. car jacks Says:

    It’s the first time I comment here and I must say that you provide us genuine, and quality information for other bloggers! Great job.
    p.s. You have a very good template . Where did you find it?

    • richdias Says:

      Thanks! Glad its of use.
      Basically came up with the template ourselves after thinking about the solution for a while.

  3. Heartburn Home Remedy Says:

    If you ever want to read a reader’s feedback :) , I rate this post for 4/5. Detailed info, but I just have to go to that damn google to find the missed bits. Thanks, anyway!

  4. Nirav Upadhyay Says:

    Can you elaborate on Point #3 in the mail to Elliot, dated Jan 14, 2009?
    I am bit confused about “Include this newly created project into your DestinationsApp project…” where to include this?

    Thanks,
    Nirav

    • richdias Says:

      Sorry I meant to say, ‘Include the newly created folder’ not project. Was a type. Have edited. Thanks.

    • Raj Says:

      Hello Heartburn home remedy,
      Could you update the missed bit here. So that it will be useful for all.
      Raj

  5. Nirav Upadhyay Says:

    Hi Richard,

    Thanks you for your reply.
    I am newbie to Sitecore. I have not taken a training on Sitecore 6, just going through the resources. Pardon me for taking your time.

    Since you are an expert in Sitecore. We think you can help us in regarding this:

    Please provide us the step by step development document/guide for Sitecore CMS 6 from scratch.
    We have an immediate requirement to develop a portal in Sitecore 6.

    We have to create a portal with pages having Common Header, Left Column and Footer. The site also will refer external .net Dlls for Some data. The pages will have grids, third party chart controls etc with customized coding based on the data from external Data.

    We are very confused by reading the scattered documents(as we haven’t got training). How can we approach this?

    - How to start with this.

    - Maintaining same look and feel for multiple pages ( Common Headers/Footers etc)

    - Using third party controls

    - Setting up the dev environment for Team Foundation Server and VS 2008 for Sitecore.

    Please provide your valuable inputs.

    Thanks in advance,
    Nirav
    nirav.eng.comp@gmail.com

    • richdias Says:

      Nirav, there is far too much here to simply document.
      The best advice I can give you is:

      Go through the developer cookbook: http://sdn5.sitecore.net/Developer/Developers%20Cookbook.aspx – The fundamentals of a successful sitecore solution design is not really different between V5.3 and V6, can I assume that you have had 5.3 training?

      Try get your hands on the Nicam sitecore demo site a dissect how it works.

      • Nirav Upadhyay Says:

        Thanks Richards,

        Nope, i have not taken training on any Sitecore versions.
        I am totally new to Sitecore and starting with 6. :(

        So far i am really confused by reading lots of docs and pdfs.

        Can you simply elaborate or guide me on how to start in a Sitecore 6 from scratch? I will pickup the rest from docs.
        Like…
        - First step creating website.
        - How to create a page with proper formatting like headers/footers/main content/left menu…

        If you have any screenshots for the above steps please send it to me on my email address: nirav.eng.comp@gmail.com if it is not difficult for you. It will be very valuable for me.

        Thanks,
        Nirav

  6. Raj Says:

    Hello Richard,
    Thanks for this useful blogpost. It gives me hope for my current problem.
    I am also in the Same scenario, can you detail me the final approach taken for setting this up. I want multiple web sites in one installation. Layouts/sublayouts/code related to each website should be in separated folder/dlls.
    Did Eliot’s workaround succeeded without any issues.
    Please provide me with some inputs on this as it is very urgent. I have created a single website as cookbook.
    How can I make separation here?
    I just tried for adding folders inside layout and it gives me error that layout not found.
    Sitecore content editor:
    -Created a folder under layout
    -Moved the layout there
    -Assigned the moved layout to the item.
    Visual studio.
    - Added a folder under layouts.
    - Moved the layout there.

    I need for the sublayout too the same behaviour.
    Expect your expert inputs.
    What do you suggest.?

    Thanks you in advance,
    Raj

    • richdias Says:

      The latest approach I am taking is to create another web application project at the same level as the Main Web App and Common Project.
      This project is only used to create .ascx controls.
      Upon successful build, the dll will be places in the bin of the main web app and the .ascx files are copied through to the main web apps layouts/site folder.
      This way I have a seperate DLL for the controls made in the second web application.

  7. Raj Says:

    Hi Richard,
    I have posted a comment already but not displayed till. So, Posting again.
    Can you detail me about the final approach taken for this? I have a same requirement(1 Sitecore installation and multiple Websites) and also I have to restructure the website accordingly.
    Layouts/Site1/.aspx
    Sublayouts/Site1/.ascx etc.
    How successful is the method discussed by you and Eliot? Can you give me some inputs? It is very urgent for me.? Your help in this is appreciated.

    Thanks,
    Raj

    • richdias Says:

      Hi Raj,
      Sorry for the late response.
      I have not tried the Virtual directory approach. I would say that you should stick to the initial approach I have suggested because this has been tried and tested.

  8. Raj Says:

    Hi Richard,
    Thanks for that update. The layout issue i mentioned is resolved.
    I will check this and let you know. So do you mean to say that one web.config(of Sitecore) for all applications under Sitecore?
    By default there is a Home default node what should be done to this.
    Can you elaborate the Step 6 in detail from your reply to eliot(not an expert in sitecore), what to do in Sitecore, and what to do in the web.config.?

    Thank you again,
    Raj

Leave a Reply