Blog

How to set up MongoDB for Sitecore

Step 1: Download and Install MongoDB in the following path (c:\mongodb)
Step 2: Create folders and configuration file
Step 2.1: Create a folder (c:\mongodb\data)
Step 2.2: Create a folder (c:\mongodb\data\db)
Step 2.3: Create a folder (c:\mongodb\data\log)
Step 2.4: Create a file mongod.cfg inside (c:\mongodb\config) that also needs to be created
Step 2.5: Insert the following into the file that you created (mongod.cfg):

systemLog:
destination: file
path: c:\mongodb\data\log\mongod.log
storage:
dbPath: c:\mongodb\data\db

Step 3: Install the MongoDB service

sc.exe create MongoDB binPath= "C:\mongodb\bin\mongod.exe --service --config=\"C:\mongodb\config\mongod.cfg\"" DisplayName= "MongoDB" start= "auto"

Step 4: Start the MongoDB service

net start MongoDB

Step 5: Create the Databases

Step 5.1:

use admin

Step 5.2:

db.createUser({user: "USERNAME",pwd: "PASSWORD",roles: [ { role: "userAdminAnyDatabase", db:"admin" }, { role: "root", db:"admin" } ] })

Step 5.2:

db.auth("USERNAME", "PASSWORD")

Step 5.3:

use analytics
db.createUser({user: "USERNAME",pwd: "PASSWORD",roles: [ { role: "readWrite", db:"analytics" } ] })
use tracking_live
db.createUser({user: "USERNAME",pwd: "PASSWORD",roles: [ { role: "readWrite", db:"tracking_live" } ] })
use tracking_history
db.createUser({user: "USERNAME",pwd: "PASSWORD",roles: [ { role: "readWrite", db:"tracking_history" } ] })
use tracking_contact
db.createUser({user: "USERNAME",pwd: "PASSWORD",roles: [ { role: "readWrite", db:"tracking_contact" } ] })

Step 6: Add the following to the ConnectionStrings.config

<add name="analytics" connectionString="mongodb://USERNAME:PASSWORD@localhost/analytics"/>
<add name="tracking.live" connectionString="mongodb://USERNAME:PASSWORD@localhost/tracking_live"/>
<add name="tracking.history" connectionString="mongodb://USERNAME:PASSWORD@localhost/tracking_history"/>
<add name="tracking.contact" connectionString="mongodb://USERNAME:PASSWORD@localhost/tracking_contact"/>

To view the databases that you created. I recommend to download RoboMongo. Install it and create a basic connection name is “Sitecore” and see them all.

How to create a package in Sitecore

If you have built something that you would like to share with the whole team, so everyone can install it on their own instances of Sitecore. This simple tutorial will help you do that.

First obviously login into your Sitecore Instance, and click on Desktop and start up Package Designer from the Development Tools

Sitecore > Login > Desktop > Development Tools > Package Designer

1

Next Window you will see is the Package Designer, so you will need to fill out the Metadata fields and select sources:

2

After everything is filled out you will go ahead and select Sources, by clicking on Items Statically.

3

Select your files that you want to be included in the actual package. In the screenshot below you can that I have included content item:

4

Click Next specify source name that will be the name of the package and will appear on the left under sources, and just click Next and then Close.

After you are done with everything you will be back to the Window that we have started at, and you will click Generate Zip.

5

Click Next and you will see the window that will have a download button:

6

Just click the world button with green arrow and share it with the world.

Hope you enjoyed this! Do not hesitate to ask questions.

Sitecore: Create your first rendering component

We are going to be creating a rendering component. It will be a very simple component, you will have an idea how everything works, and then you will go ahead and create something more complex.

First things first is the checklist:

  1. Create a physical file in the path inetpub\wwwroot\tonySample\Website\xsl. 
  2. Create an item in Content Editor Tree in the Layouts\Renderings.
  3. And then you can insert wherever you like.

So lets begin:

Create an XSLT file, name it something that will be familiar to you, we will use an example and call it (component_tony.xslt).

sitecore_sample_rendering_component_tony

Next we will add some code to the XSLT file:

sitecore_sample_rendering_component_code

sitecore.component/component_tony.xslt – Get the raw code here

Now save it and lets go to the Sitecore.

Create a Rendering Component, name it whatever you wish, as you can see below I named my component Tony Rendering Component.

sitecore_content_tree_layouts_sample_rendering_component

In the Data section of your component item. Go ahead make the following changes:

sitecore_sample_rendering_component_data

Now if you insert this component somewhere on the page, it will show you the content that is included in the XSLT file.

Enjoy! Hope this helps. If there is any questions, please do not hesitate to ask.

SiteCore Power Shell Extension Web API

This Tutorial will allow you to create a custom script that you can execute from the browser URL.

power-shell-extension-url

What do you need in order to perform this tutorial

SiteCore PowerShell Extension

Download and Install SiteCore PowerShell Extension. Access it from the SiteCore Desktop.

power-shell-extension

Add a small custom Script:

script

This script will give you last 20 lines of the log file. Or you can specify a different log file name and different length of lines. Commands are below

if($length -eq $null){
$length = 30
}

if($logType -eq $null){
$logType = “log”
}

Get-ChildItem “$($SitecoreLogFolder)\$LogType*.*” |
Sort-Object -Descending LastWriteTime |
Select-Object -First 1 |
Get-Content -Tail $length

In order for this to work. You need to enable restfulv2 in your Cognifide.PowerShell.config. which is located in Website\App_config\Include\Cognifide.PowerShell.config

<restfulv2 enabled=”true” requireSecureConnection=”false“>

Commands that you can run from the browser while logged in are the following:

Hopefully this helps.

If you have any questions ask me on tmamedbekov or comment below.