How to create a user in Sitecore and give them special access to Sitecore Content

So today, I will demonstrate how to create a user that will have access only to a specific Content Item in Content Editor.

Requirement:

Create a user that will only have access to edit one specific item in Content Editor

Execution Steps:

In this tutorial we will be using  the following Sitecore tools:

  • User Manager
  • Role Manager
  • Security Editor

First lets create a user and name him Author:

user-1

Go to Sitecore LaunchPad and select User Manager. Click New and enter the values, depending on your requirements should look something like this:

user-2

Click Next and Close.

Next Step lets make user “author” member of “sitecore\Author” role.

Select the user and click Edit button on the ribbon.

user-3

Switch to the tab “Member Of” and click “Edit”

user-4

From the list of Roles select “sitecore\Author” and add it and then click OK.

The reason I am using this Role, because this OOTB role created by Sitecore, and it disables a lot of administrative functionality.

user-5

Now lets give this user access to edit only one specific item.

 

Select the user “author” from the list and click “Security Editor” on the ribbon.

user-3

In the next window you will make the following changes.

Make sure that the user “author” is selected. Then Allow to Write to the Item “Configurations” and Deny “FXM” to Read. Everything under Configurations will inherit the permissions.

user-6.PNG

Everything is in effect immediate, there is no Save or Okay buttons. So be careful what you are doing. You can make mistakes very easy.

This is what you should see when you login with Author credentials.

user-7

Sitecore recommended practice is to create roles that have special permissions, and then assign those roles to users. In this example I would not create a Role for the user because I only have a requirement for one user to touch one item, and this will never change.

If you have any question, please do not hesitate to reach out to me, comment here or connect with me on Twitter @tmamedbekov

Sitecore Experience Editor with Angular JS Integration

I have been challenged to integrate Angular web-application with Sitecore, I needed to create an ability for Content Authors to edit content that is coming from Angular Application.

So lets think for a second, I have an angular application that has all of my design and all of my logic and templates and controllers and so on. Sitecore is serving as a database. Customer would like to edit content in Experience Editor, not in the Content Editor, they would like to edit everything on the web page, the only way to do it, is to build the web site in Sitecore recommended way, by using the the MVC way. Create Layouts, Controllers, Models and so on. But we don’t want to rebuild it all. We would like to do this faster without rebuilding it.

First thing is to figure out how to inject MVC into the Angular Template, within the Sitecore Layout. After my research has been done I stopped on an article by Sitecore MVP Alexander Smagin (Using Angular Directives in Sitecore Edit Mode).

In this tutorial I will show, how you can get going really fast without rebuilding everything in Sitecore.

What we will need to have in our project:

  1. Sitecore Layout (Layout.cshtml)
  2. Sitecore Controller (AngularController.cs)
  3. Angular Template (index.html)
  4. Angular Module (myangular.js)
  5. Sitecore Template
  6. Sitecore Layout
  7. Sitecore Item

So lets begin!!!

Step 1: Lets Create a Sitecore Template

If you do not know how to create a Sitecore Template , here is a quick tutorial (How to create a Sitecore Template?)

  • Content
    • Title – Single-Line Text
    • Text – Rich-Text Editor
    • Image – Image

Create a template

Save your work and add __Standard Values.  You result should look something like this.

Sitecore Tree View

Step 2: Lets Create a Sitecore Layout (Layout.cshtml)

Lets go ahead and open Visual Studio and create a Layout. Right click on Views folder and a View and name is angularLayout.cshtml  and paste the following code in the angularLayout.cshtml:

We will add Controller and Angular Module next.

Step 3: Lets Create a Sitecore Controller (AngularController.cs)

Go to Controllers folder and add new Controller and name it AngularController.cs and paste the following code in there:

Step 4: Lets Create an Angular Module (myangular.js)

Go ahead and create myangular.js under the Scripts folder, and paste the following code in there:

Make sure to change your templateUrl.

And finally you can either add your own template or use this one for the learning purposes. This is just a sample, use your imagination how you can go about it.

Step 5: Lets Create an Angular Template (index.html)

This is just a simple angular template that uses Bootstrap, and it will bind the content with the Sitecore (@Html.Sitecore().Field) method.

Now since we have done all the work in Visual Studio. Lets go ahead and build it, and Publish it to Sitecore.

Once Everything is Published we will go ahead and connect all of the code that we have done to our template, and start creating items, based on this template.

Step 6: Lets Create a Sitecore Layout in Content Editor.

You should have something similar to this:

layout_tree

And your Data information for this Layout will look like this:

layout_data.PNG

How we will have to go back to our __Standard Values and add this Layout to the Template that we have created.

So go and select __Standard Values and select Presentation Details

standard-values.PNG

Select the appropriate Layout and you are good to go.

Create and item and you open in Experience Editor, and this item renders the layout that comes from the .html page with angular directive, you can edit everything, that you see on the page.

final-product.PNG

If you have any question, please do not hesitate to reach out to me, comment here or connect with me on Twitter @tmamedbekov

Thank you Alexander Smagin for his great post Using Angular Directives in Sitecore Edit Mode

How to create a Sitecore Template?

Open your Experience Editor. Right click on the desired folder and Insert > New Template

template_1.PNG

Provide a name for your Template, click Next and then Next and then Close

template_2.PNG

And finally you should see something similar to this:

template_3.PNG

Now on the right side you build out the structure of the Sitecore Template.

builder.PNG

You can have multiple sections, multiple names and type according to the design requirements.

When you build and Item in the Content tree based on this Template you will see something similar to this:

content.PNG

Enjoy!!! If you have any question do not hesitate to comment and ask questions!

Move Items between folders on specified day in Sitecore Content Editor

Lets imagine for a second that you have a lot of content Authors, and they are creating new items every day. At some point in the future, these items need to be moved to an Archive. Out of the box Sitecore has a functionality of Archiving Items, but it all goes into the Archive Application that you can access from Desktop > All Applications > Archive

I would like to achieve something different, I would like to move items from News folder to News Archive folder, illustrated below:

Auto Archive in Sitecore

In order to achieve this, you will need to create a News Template with certain fields, see the screenshot below:

Template

So then you will create a News item based on the News Template you just created.

You should see something similar to the screenshot below:

news-item

After you have all the items created in Sitecore Content Editor, now lets go to the Visual Studio and write some code:

After you build and deploy the code, you will need to add some custom Configurations. So go ahead into the folder Website>App_Config>Include>Project>ItemMoving.config and insert the code below, this will patch the actual Sitecore.config

So this agent will execute every minute, and search for the Expiration Date within the items, that are in the News (Source Folder) and move the expired files to the News Archive (Destination folder). If you have any questions do not hesitate to ask.

Acknowledgement:
Richard Seal – https://sitecore.stackexchange.com/users/70/richard-seal
Dannon Gruver – https://www.linkedin.com/in/dannongruver
This blog post is based on the post from Stack Exchange:
https://sitecore.stackexchange.com/questions/5974/move-items-between-folders-programmatically
Note that this blog post has no intention to claim anybodies work as my own. This blog post is for informative purposes only.

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.