Sitecore MongoReportDemo Part1 Setup

25
So you want to write a report… Part 1: Setting up a sitecore development environment from scratch If you already know how to do this, go ahead and skip to Part 2 (once it’s out). Prerequisites and First Instance First, go ahead and make sure a compatible edition of MongoDb is installed. I’m running 3.0.3 so take that as you will. If you install from the mongo installer, you may want to enable mongodb as a windows service. The following command line will do so: mongod.exe --install --verbose --logpath "C:\Logs\Mongo\Log.txt" --serviceName "Mongo 3.0.3 (27017)" --serviceDisplayName "Mongo 3.0.3 (27017)" --serviceDescription "Mongo 3.0.3 (27017)" --dbpath "D:\Data\MongoDb" Also Visual Studio And SQL Server And Sitecore Rocks I’d Recommend TDS by Hedgehog, but this’ll work without it. You just won’t be able to version and sync and all that jazz. For using the SIM tool (described shortly) you’ll need to change the user that the sql server service is running under. Open the services.msc management console. Then open the properties of the sql server service. Goto the Log On tab and change the Log on as account to “Local System account”

description

Part 1: Setting up a sitecore development environment from scratch

Transcript of Sitecore MongoReportDemo Part1 Setup

Page 1: Sitecore MongoReportDemo Part1 Setup

So you want to write a report…

Part 1: Setting up a sitecore development environment from scratch If you already know how to do this, go ahead and skip to Part 2 (once it’s out).

Prerequisites and First Instance First, go ahead and make sure a compatible edition of MongoDb is installed. I’m running

3.0.3 so take that as you will. If you install from the mongo installer, you may want to enable mongodb as a windows

service. The following command line will do so: mongod.exe --install --verbose --logpath "C:\Logs\Mongo\Log.txt"

--serviceName "Mongo 3.0.3 (27017)" --serviceDisplayName "Mongo

3.0.3 (27017)" --serviceDescription "Mongo 3.0.3 (27017)"

--dbpath "D:\Data\MongoDb"

Also Visual Studio And SQL Server And Sitecore Rocks I’d Recommend TDS by Hedgehog, but this’ll work without it. You just won’t be able to

version and sync and all that jazz. For using the SIM tool (described shortly) you’ll need to change the user that the sql

server service is running under. Open the services.msc management console. Then open the properties of the sql server service. Goto the Log On tab and change the Log on as account to “Local System account”

Page 2: Sitecore MongoReportDemo Part1 Setup

Download the latest Sitecore Instance Manager Tool (SIM.Tool) https://marketplace.sitecore.net/modules/sitecore_instance_manager.aspx

Set Up your folders for using SIM Websites/SIM – The folder where your installed instances of sitecore will be

Page 3: Sitecore MongoReportDemo Part1 Setup

Sitecore – The base folder for your tools, repos, and licenses

Repos – Where to put your zips of Sitecore for install

Page 4: Sitecore MongoReportDemo Part1 Setup

SIM.1.4 – Your installation folder for SIM

Page 5: Sitecore MongoReportDemo Part1 Setup

I’m gonna assume you’re a Developer, setting up a local development environment. So

I’m not too concerned about environment security more than it works, and you won’t be hacked from the outside. So… open up SSMS and select the instance you’ll be working on. Under Security Logins. Add the “NT AUTHORITY\NETWORK SERVICE” user and set them to the following server roles:

Page 6: Sitecore MongoReportDemo Part1 Setup

So now open up SIM and make sure your configuration matches that from above.

Page 7: Sitecore MongoReportDemo Part1 Setup

Alright now install an instance:

As a note, this will modify your hosts file. Feel free to update it further if you want a

prettier URL. Actually, I would recommend it. When you try to browse to your new sitecore site, you’ll get a login failed for user ‘’. Go to your WEBSITES\SIM\<instance>\Website\App_Config folder and modify the

ConnectionString.config file. Change all the Integrated_Security=False items to True. Also, if you did anything other than the default install for MongoDb, update appropriately.

Now your site will come up all pretty. Alright! Now let’s get things started. For this

demonstration (which starts in part 2), we’ll be collecting user feedback for each page we visit (Modified Contact Facet). And then, we’ll be SPEAKing about the Experience Analytics of the matter. How well do our visitors like our page?

Page 8: Sitecore MongoReportDemo Part1 Setup

The Visual Studio Project

Start a new ASP.NET Web Application (Opening Visual Studio as an ADMINISTRATOR)

Page 9: Sitecore MongoReportDemo Part1 Setup

Start a new Empty project with references. Don’t go hosting it in Azure or testing it, unless you roll that way. But that’s not my business.

Go ahead and take a copy of your web.config from the sitecore instance and place it in

your new project. And after that Open up the properties on your project. Switch the Framework to 4.5

Page 10: Sitecore MongoReportDemo Part1 Setup

Go ahead and add a Views folder to the project then add a new view.

And fill it in with something we can test:

Okay. Let’s double check our NuGet packages. Visual studio has a habit of including the

MVC packages when we add a MVC object. Remove any packages related to Razor, MVC, etc. Don’t worry. Everything will still compile, and we’ll add references as we need them that are compatible with our Sitecore instance.

Page 11: Sitecore MongoReportDemo Part1 Setup

Now Right­Click on your project and select publish.

Select Custom Enter a Name

Page 12: Sitecore MongoReportDemo Part1 Setup

Set the publish method to File System and the Target Location to the instance you setup earlier.

Page 13: Sitecore MongoReportDemo Part1 Setup

Set the Configuration to Debug. And for the love of all things Content Managed, DON’T select the delete option.

Now Publish!!

Page 14: Sitecore MongoReportDemo Part1 Setup

Setting up Sitecore to Render our MVC View

The Desktop and Databases Bring up your site (http://mongoreportdemo/sitecore/) and if all went well you should be

at the dashboard.

Go to the Desktop. (Strictly speaking this step is skippable, but if you’ve never worked with sitecore you’ll be missing an important lesson.)

Page 15: Sitecore MongoReportDemo Part1 Setup

In the bottom right­hand corner of the desktop is an icon. Click it.

If you like, go ahead and select the “Show Database Name” that way you know which one you’re working on. Now for the beginner’s lesson in sitecore. Sitecore uses multiple databases. Core, Master, and Web are the defaults to start with. Also, there’s a reporting database hanging out in SQL Server too, but you don’t need to select it. If you want to learn more about what each of these databases do. You’ll need another article, that’s not covered here. What is covered…

Page 16: Sitecore MongoReportDemo Part1 Setup

Click on the sitecore start button. And select Content Editor

Now, the content editor is available from Launchpad; but selecting which database you’re working from isn’t. There’s the lesson. Okay, content editor…

Getting Ready for MVC You’re going to have to add a new Layout for MVC Pages. Go to

sitecore­>Layout­>Layouts and right­click to insert new layout. Let’s name it Sample

Page 17: Sitecore MongoReportDemo Part1 Setup

MVC Layout.

Then place it under the base Layouts folder, then finally select the location.

Website­>layouts. Create!

Page 18: Sitecore MongoReportDemo Part1 Setup
Page 19: Sitecore MongoReportDemo Part1 Setup

Now under the Data settings in our new layout. Update the link from .aspx to .cshtml.

Open the file system and go to your website instance. Rename the actual file here as

well.

Page 20: Sitecore MongoReportDemo Part1 Setup

Let’s add this new file to our Visual Studio project so we can modify it and publish it

when we want. The File should have the following contents: @inherits System.Web.Mvc.WebViewPage @using Sitecore.Mvc; @ Layout = null; <!DOCTYPE html PUBLIC "­//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1­transitional.dtd"> <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <title> @Html.Sitecore().Field("title", new DisableWebEdit = true )

</title> <meta http­equiv="Content­Type" content="text/html; charset=UTF­8" /> <link href="/default.css" rel="stylesheet" /> </head> <body> <div id="MainPanel">@Html.Sitecore().Placeholder("main")</div> </body> </html> So go ahead and publish again to make sure the layout file is correct.

Adding our Demo Launch Rendering Under sitecore­>Layout­>Renderings go ahead and right­click insert a new folder for our

stuff. I called it MongoReportDemo. I also like creating folder for different types of renderings. So under MongoReportDemo go ahead and create a View Renderings folder.

Under our new folder right­click insert a new View Rendering and name it after our view we created. DemoLaunch

Page 21: Sitecore MongoReportDemo Part1 Setup

Then fill in the path under the Data section.

Page 22: Sitecore MongoReportDemo Part1 Setup

Go to the sitecore­>Content section and insert from template.

Page 23: Sitecore MongoReportDemo Part1 Setup

Then from the Ribbon, select PRESENTATION, then Details to bring up the Layout Details.

Under the Default Section Click on Edit Under Layout, select Sample MVC Layout.

Page 24: Sitecore MongoReportDemo Part1 Setup

Then under Controls, add a new Control. Select your DemoLaunch Rendering, and add it to the “main” placeholder.

Page 25: Sitecore MongoReportDemo Part1 Setup

Now when you open http://mongoreportdemo/DemoLaunch you should be greeted with

If you made it this far, congratulations! You’ve completed part 1, and now have a local development instance tied to your Visual Studio project. In part 2, we’ll be exploring the configuration of facets and they are stored in MongoDB/xDB.