Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 209

Sitecore 9.

2
REFERENCE GUIDE
Contents
Overview...............................................................................................................................................................3
Installation............................................................................................................................................................3
Pre-requisites....................................................................................................................................................3
Tools..................................................................................................................................................................4
Setup guide.......................................................................................................................................................5
Installing Solr.................................................................................................................................................5
Sitecore Rocks Installation..........................................................................................................................14
Configure Sitecore NuGet source................................................................................................................16
Installing Sitecore 9.2..................................................................................................................................17
Sitecore components..........................................................................................................................................25
Launchpad.......................................................................................................................................................25
Content Editor.................................................................................................................................................26
Experience Editor............................................................................................................................................27
Desktop...........................................................................................................................................................27
Control Panel...................................................................................................................................................28
Sitecore Rocks.................................................................................................................................................29
Content tree........................................................................................................................................................38
Templates...........................................................................................................................................................42
Field types.......................................................................................................................................................42
Templates........................................................................................................................................................65
Data Templates...........................................................................................................................................65
Page Template.............................................................................................................................................68
Branch Template.........................................................................................................................................68
Rendering Parameter template...................................................................................................................73
Command templates...................................................................................................................................76
Template inheritance......................................................................................................................................77
Standard values...............................................................................................................................................80
Media Library......................................................................................................................................................84
Layouts................................................................................................................................................................87
Layouts............................................................................................................................................................87
Renderings......................................................................................................................................................95
Placeholders..................................................................................................................................................107
Datasources...................................................................................................................................................122

1
Field Datasources......................................................................................................................................122
Rendering Datasources.............................................................................................................................122
Miscellaneous...................................................................................................................................................129
Multi-Site.......................................................................................................................................................129
Multi-lingual..................................................................................................................................................131
Buckets..........................................................................................................................................................135
Compatible Renderings.................................................................................................................................141
Workflows.........................................................................................................................................................144
Schedulers.........................................................................................................................................................153
Forms................................................................................................................................................................ 160
How to create a Sitecore Form?....................................................................................................................160
Where do we get the data related to a form?...............................................................................................175

2
Overview
Sitecore is leading digital experience software used by organizations globally to create seamless, personalized
digital experiences. Sitecore is an integrated platform powered by .net CMS, commerce and digital marketing
tools. Sitecore’s key product is the Sitecore Experience Platform (XP) which combines their powerful content
management system (CMS) Sitecore Experience Manager and Sitecore Experience Database (xDB).

Sitecore is constantly evolving, with each update offering new innovative tools for its users. The cloud-first
digital experience platform also offers shopping experiences through Sitecore Experience Commerce. The
question, ‘what is Sitecore?’ is a common one, and understandably as it’s often described as a web content
management platform. Gartner rated Sitecore highly in their Gartner Magic Quadrant 2017 and have gone on
to recognize the software more recently.

Sitecore describes itself as a ‘Customer Experience Platform CXP).

Installation
Pre-requisites
a. OS

The below operating systems are supported:

Windows Server 2019

Windows Server 2016

Windows 10 (32/64-bit)

b. Database

Below database servers are supported:

Microsoft SQL Server 2016 SP2 and 2017

MongoDB Server 4.0.5 – This is required if you are going to use MongoDB for the Experience Database
(xDB) or as a Session State Provider.

Do not forget to enable contained databases in MS SQL Server!

In order to enable contained databases on SQL Server, run this SQL script through SQL Server
Management Studio:

EXEC sp_configure ‘contained’, 1;

3
RECONFIGURE;

c. PowerShell

Microsoft PowerShell® version 5.1 or later is required.

To quickly check, you can always open a PowerShell command prompt and run the following
command:

$PSVersionTable.PSVersion

d. IIS

Only one version of IIS is supported:

IIS 10

e. .NET requirements

Sitecore XP 9.2 requires .NET Framework 4.7.2.

Sitecore Identity server requires .NET Core 2.1.7 Windows Hosting Module.

Reference links

https://tothecore.sk/2019/07/22/sitecore-9-2-initial-release-installation-guide-for-development-machine/

Tools
1. Visual Studio 2017
2. SQL Server 2017
3. Management Studio
4. SOLR 7.5+ (Preferred is the latest one – I installed 7.7.2)
5. NSSM – to host SOLR as a service.
6. Sitecore Rocks

4
Setup guide

Installing Solr

1. Download latest Solr from https://lucene.apache.org/solr/downloads.html


2. Extract it and place it in a desired folder ex. D:\Sitecore Demo\solr-7.7.2

3. Open command prompt in administrator mode.


4. Navigate to D:\Sitecore Demo\solr-7.7.2 using ‘cd D:\Sitecore Demo\solr-7.7.2’ command.
5. Now we should run SOLR. Use command ‘bin\solr start’

6. There can be issues while you run SOLR if there is no JAVA installed on your system.

5
7. If that is a case then you can install the JAVA from here.
8. Once you install a JAVA, you need to set environmental variables for your system.
9. Note down the path for JAVA, typically “C:\Program Files\Java\jdk1.8.0_221” and “C:\Program
Files\Java\jre1.8.0_144”
10. Go to Control Panel >> User Accounts

11. Click New and add both the variables in the below screen.

12. Let’s check if the SOLR dashboard is working fine.


13. Browse http://localhost:8983/solr

6
14. Now we need to create self-signed certificate to make the SOLR run on https.
15. In the command prompt, navigate to your JRE folder, in my case it is: C:\Program
Files\Java\jre1.8.0_221
16. Run below command to Create Keystore:
bin\keytool.exe -genkeypair -alias solr7-ssl -keyalg RSA -keysize 2048 -keypass secret -storepass secret
-validity 9999 -keystore solr7-ssl.keystore.jks -ext SAN=DNS:localhost,IP:127.0.0.1

7
17. Run below command to generate a certificate.
bin\keytool.exe -importkeystore -srckeystore solr7-ssl.keystore.jks -destkeystore solr7-
ssl.keystore.p12 -srcstoretype jks -deststoretype pkcs12

18. Keep password as ‘secret’ as it is easy to remember.


19. The certificate will be generated in your JRE folder. We will install it in our computer.
20. Double click on the certificate “solr7-ssl.keystore.p12”.

8
21. Select ‘Local Machine’ and click Next.

22. Click Next. The password will be secret.

9
23. Select the “Place all certificates…” option and click Browse

24. Select the Trusted Root Certification Authorities and Click OK.

10
25. Click Next and Finish.
26. You will get a pop up with the message as “The import was successful”.
27. Now move the Keystore and Certficate file from JRE folder to your “server\etc” folder within SOLR
folder i.e. “D:\Sitecore Demo\solr-7.7.2\server\etc”

28. We have to enable the SSL in SOLR.


29. Navigate to bin folder and open file solr.in.cmd ie. D:\Sitecore Demo\solr-7.7.2\bin\solr.in.cmd

11
30. Search for “SOLR_SSL_KEY_STORE” in the file and uncomment the below lines. Also remember to
update the password if you have not used “secret” as your password and update the name .jks and
.pk12 file to solr7 instead of solr

12
31. In command prompt, navigate to SOLR folder i.e. D:\Sitecore Demo\solr-7.7.2
32. Run the solr using command “bin\solr start”

33. Let’s browse the SOLR dashboard using the URL: https://localhost:8983/solr

34. Now our SOLR is set up and we are ready to go for Sitecore installation but before that we need to run
SOLR as a service.
35. To run SOLR as a service, we need NSSM.
36. Download NSSM from here.
37. Extract it and place in a desired folder. Ex. D:\Sitecore Demo\nssm-2.24

13
38. Now open command prompt in administrator mode and run below command
“D:\Sitecore Demo\nssm-2.24\win64\nssm.exe” install SOLR7.2

39. The NSSM pop up will be appear in which we need to fill the details regarding our SOLR instance. Fill it
according to the below screen.

40. Click Install service.


41. A pop up will appear with the message “Service SOLR7.2 installed successfully”.
42. Again browse SOLR dashboard and check if it is accessible - https://localhost:8983/solr
43. In case if it is not accessible then go to services using Run (Win + R).
44. Use command services.msc

14
45. Search service SOLR7.2 and Start it.

46. Now browse the SOLR and check if it is accessible.

Sitecore Rocks Installation

Install Sitecore Rocks from Visual studio extensions or download it from Visual Studio marketplace and install
it.

1. Open Visual Studio in administrator mode.

15
2. Go to Tools >> Extensions and Updates.

3. Click on Online and search for Sitecore rocks.

4. Click on Download.
5. You will get a new screen VSIX, click Modify.

6. Close Visual Studio if open.

16
7. Once it is installed, you will see below screen.

8. We have completed installing Sitecore Rocks extension in the VS 2017 but we will connect it with
Sitecore instance once we have installed Sitecore.
9. In case you want to download the extension and install then you can download it from below URL.
https://marketplace.visualstudio.com/items?itemName=JakobChristensen.SitecoreRocks

Configure Sitecore NuGet source


1. Open Visual Studio in administrator mode.
2. Go to Tools >> Options.

3. Go to NuGet Package Manager >> Package Sources.

17
4. Click on + button to add a new source, Name: Sitecore Package & Source:
https://sitecore.myget.org/F/sc-packages/api/v3/index.json

5. Click Ok.

Installing Sitecore 9.2


Let’s download the Sitecore 9.2 from the Sitecore portal and start installing it.

1. Go to Sitecore Portal to download the Packages for XP Single.

2. In case you are not logged in, you will have to log in to Sitecore portal and accept the terms &
conditions to download the file.
3. Extract the downloaded file and place it in the desired folder, ex. D:\Sitecore Demo\Sitecore
Installation files

18
4. Extract XP0 Configuration files zip and the folder should look like below:

5. Copy the license file (license.xml) in this folder.


6. Now we need to install SIF 2.1 and Powershell 5.1 or above.
7. First check if the PowerShell version is 5.1 or above else download and install it from here.
8. Once the PowerShell is installed. Open it in administrator mode and run below commands one by one.
a. Register-PSRepository -Name SitecoreGallery -SourceLocation https://sitecore.myget.org/F/sc-
powershell/api/v2 -InstallationPolicy Trusted
b. Install-Module SitecoreInstallFramework –Force
c. Update-Module SitecoreInstallFramework
9. I have already installed, so I am getting error as it already exists.

10. Once we are done with the PowerShell commands, we can navigate to Sitecore installation folder with
the command – ‘cd “D:\Sitecore Demo\Sitecore Installation files”’
11. Run the command “Install-SitecoreConfiguration -Path .\Prerequisites.json”.

19
12. And the prerequisites will be downloaded and installed by the powershell.

13. Once the process is completed, it is recommended to restart the system so that all changes can be
effective.
14. Once the machine is restarted, navigate to Sitecore installation folder.
15. Open XP0-SingleDeveloper.ps1 file so that we can update some attributes before we can install it.

16. From the above you can see that we have done couple of changes which are:
$Prefix (which means name of the website) : SitecoreDemo
$SCInstallRoot (which means installation folder) : D:\Sitecore Demo\Sitecore Installation files
$SolrRoot (which means solr folder) : D:\Sitecore Demo\solr-7.7.2

20
$SolrService (which means the name of the service which we created) : SOLR7.2
$SqlServer (which means name of the server) : ROHANKE (name of my SQL server)
$SqlAdminPassword (password of sa user) : cybage@123 (in case IS team has installed your SQL
server)
17. Save the changes to the script file.
18. Open PowerShell in administrator mode and navigate to Sitecore installation folder using a command
– ‘cd “D:\Sitecore Demo\Sitecore Installation files”’
19. Run the command – ‘./XP0-SingleDeveloper.ps1’

20. The process of installation will start.

21
21. In case you get below error

22. We need to set the TLS to 1.2 using below command


[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

23. Again run the command – ‘./XP0-SingleDeveloper.ps1’ to install the Sitecore.


24. In case you get the below error at the end of the installation process i.e. while performing task 88

25. It is because the script was not able to rebuild the indexes. But the main issue is in the task 89, the
script generates password for our instance.
26. Let’s set the password of admin user to ‘b’ using SQL query.
27. Login to the SQL server, select Core DB and execute below query.
UPDATE

22
[aspnet_Membership]
SET
[Password]='qOvF8m8F2IcWMvfOBjJYHmfLABc=',
[PasswordSalt]='OM5gu45RQuJ76itRvkSPFw==',
[IsApproved] = '1',
[IsLockedOut] = '0'
WHERE
UserId IN (
SELECT UserId FROM dbo.aspnet_Users WHERE UserName = 'sitecore\Admin'
)

28. Let’s login to Sitecore and try to rebuild these indexes.


29. Browse URL (http://sitecoredemo.sc/sitecore) to login to Sitecore. Credentials are as below:
Username: admin / password: b

23
30. You will see the Launchpad. Click on Control Panel

31. Click on ‘Populate Solr Managed Schema’ under Indexing Section and Click Populate.

32. Once all are succeed, click Close.

24
33. Click on ‘Deploy marketing definitions’ next to Populate Solr Managed Schema.

34. Click Deploy. This will take quite some time.


35. Once the definitions are successfully deployed, Click Close.

25
36. Click on Indexing Manager which is below ‘Populate Solr Managed Schema’.

37. Select all the indexes and Click on Rebuild.

26
38. Once the rebuild is done. We are done with Sitecore 9.2 installation.

Sitecore components
There are various components with in the Sitecore Dashboard. Let’s understand each of it one by one.

Launchpad

The above screen is an entry point to the Sitecore Dashboard also known as Launchpad. There are various
applications and these are accessible based on the login user’s access roles. Right now we logged in as an
admin hence we are able to see all the applications on the Launchpad.

All the applications are mainly divided into 4 categories – Marketing Applications, Content Editing, Control
Panel and Access Management.

According to the project, developers work in all 4 categories, the Content Editor works in Marketing
Applications and Content Editing categories only.

As name suggests Marketing Applications are for making the marketing team’s work easy and at the same
time making the user experience for the end users more enjoyable. Content Editing is totally based on the

27
Content of the site. Control Panel is to control or check different things like performance, indexing, etc. Access
Management is totally related to the users and the roles assigned to them.

The 3 main applications which we frequently use are Content Editor, Experience Editor, Desktop, and Control
Panel. In earlier versions, the first 3 applications were known as interfaces.

Content Editor
This is the first application under Content Editing category.

The Content Editor was designed for those with higher levels of Sitecore experience and more familiarity with
the platform. It is home to the Content Tree where all the pages, media, and data of the website live. If you’re
working in a multi-site instance, all the websites in said instance will be displayed in the Content Tree, and the
content for each site will live below the home node of each website. Everything you do in the Experience
Editor is reflected in the Content Editor.

Content tree and the Ribbon constitute the Content Editor. We will go in detail to discuss each node in the
Content tree in the upcoming sections.

28
Experience Editor
This is one more option for the content editors to update the content of the site.

The Experience Editor is a WYSIWYG (What you see is what you get) specifically designed to let contributors
edit things that are VISIBLE on the page – images, text, logos, links, and component-specific personalization.
When you access the Experience Editor, through the Launchpad, Sitecore takes you to a client facing view of
your website. This is incredibly helpful for changing text and images, witnessing the edits in real time, and
allows you to navigate through the site the same way a visitor would.

This is for the content editors who are non-technical and can easily get the work done in this editor.

Desktop
When you are accessing Sitecore Desktop you will find rich set of features using which you can

 Create and Install packages


 View files using File Explorer
 Clean up database using Control Panel
 Change the desktop background
 Change the application options
 Access different Databases (Core, Web, Master)
 Many more

Sitecore Desktop user interface has many feature options compare to Content Editor and Experience Editor.

29
The below is how the Desktop interface looks:

Control Panel
The control Panel application has rich features that help the developers to troubleshoot the issues, as well as
do the house keeping tasks. Also routine tasks can be carried out using the Control Panel tools/features.

Some of the helpful features are:

 Rebuilding Indexes
 Rebuild link databases
 Install packages – Sitecore update
 Scan databases for broken links
 Clean up databases
 Localization (Language) & Security (Users and Roles)
 View License details
 Change Desktop Background
 Change Password

The control Panel dashboard looks like the below screen.

30
Sitecore Rocks
Sitecore rocks is not an application under the Launchpad. This is a tool which helps the developer to develop
the solution faster as the developer is able to access the solution, Sitecore content tree and File manager
under one roof i.e. Visual Studio.

Let’s see how to configure it. In the previous section, we had downloaded and installed in our Visual Studio.
Now let’s create one Visual Studio solution and configure it with our Sitecore instance.

1. Open the Visual Studio in administrator mode.


2. Create a new project – Sitecore Demo.

3. Select “ASP.NET Web Applications” under Web. Name it ‘SitecoreDemo’, select .Net framework 4.7.2.

31
4. Select the location where you want the solution to be stored. My path is ‘D:\Sitecore
Demo\CodeBase’.

5. Click OK

32
6. Select the Empty solution and check MVC checkbox.

7. Click Ok
8. The project will be created with solution name as SitecoreDemo.
9. Let’s create a folder Libraries in the Solution.
10. Right click on the Solution >> Add >> New Folder

11. Name it Libraries

33
12. Right click on Libraries folder >> Add >> Existing Item..

13. Navigate to the bin folder of the Sitecore instance (C:\inetpub\wwwroot\SitecoreDemo.sc\bin). So


that we can add Sitecore.Kernal.dll and Sitecore.Mvc.dll to the Libraries folder.
14. Select both the dlls and Click Add.

34
15. Right click on References folder and add the references of these dlls from Libraries folder.

16. Click OK
17. Right click on the solution in Visual Studio >> Add >> Existing Item.
18. Select the Global.asax and Web.config from the Sitecore Instance folder
(C:\inetpub\wwwroot\SitecoreDemo.sc)

19. Click Add.


20. Click ‘Apply to all items’ and Click Yes
21. Delete the Gobal.asax.cs file.

35
22. Now expand the Views folder in VS. Right click on Web.config file under Views and go to its properties.

36
23. And change the Build Action attribute to None.

24. Now we are ready with the solution and hence let’s publish it to the Sitecore instance.
25. Right click on the solution >> Publish..

37
26. Click on Folder. Browse to Sitecore instance folder (C:\inetpub\wwwroot\SitecoreDemo.sc)

27. Click on Advanced. Change the Configurations to Debug

28. Click Save.


29. Click Publish.
30. The solution will be built and published to Sitecore instance.
31. Once publish is completed, browse the Front end (http://sitecoredemo.sc/) and Back end site
(http://sitecoredemo.sc/sitecore) and verify if everything is working as expected.
32. Now we will set up the Sitecore Rocks

38
33. Go to Views tab >> Toolbars >> Sitecore – Sitecore Explorer

34. You will be able to see one more tab ‘Sitecore’ in VS now. Click on New Connection

39
35. Paste the Sitecore URL “sitecoredemo.sc” in Host name and click on Test

36. Either you will get – “Yes, it works” or else a pop up will appear like the below one. If it is Yes it works
then you can skip below 3-4 steps.

37. Click Yes. Click Update All.

40
38. Select the root folder of the website.

39. Click OK.


40. If it is ‘Yes it works’ then Click OK.
41. Click on Sitecore Explorer

41
42. Expand sitecoredemo.sc node

43. Now we can access all the databases and the website folder within Visual Studio.

This completes our configuration of Sitecore Rocks and Visual Studio solution.

Content tree
In this section, we will go through the different nodes in the Content tree. The nodes are as below:

 Content
 Forms
 Layout
 Media Library
 System
 Templates

Each section has its own importance and hence all the items are divided under these nodes – 3 of them are
very simple which we will understand first.

42
1. Content:
In the content node, we have all the items related to website and all based on the templates that are
created by us. Content in sense – pages, carousals, widgets, navigations, banners, etc.

2. Forms:
As the name suggests, these node will have all the forms in our website which we created to capture
end user’s inputs. Also this doesn’t mean that we will create only Sitecore forms. We can have our
own custom forms that are not part of Sitecore.

3. Media Library:
This is a place where all the Media files are placed. Be it a images, videos, documents, files,
attachments, etc all are stored here. We can create our own folder structure and add the media files
accordingly.

43
4. Layout:
This is place where the presentation layer of our website is placed. All the Views and Controllers that
return views are mapped by creating renderings and the master page is known as Layout in Sitecore.

44
5. Templates:
As we know that all the items are based on the templates, all our custom templates are placed under
this node whether it is data template, command template, branch template or Rendering parameter
template.

45
6. System:
As the name suggests, this is where all the configurations sits in. Also out of the box features sits in
here. Some of them are workflows, schedulers, languages, etc.

46
Templates
Field types
There are large set of field types provided by Sitecore which serves our requirements. Let’s go through each of
it one by one.

1. Single-Line Text
This field type gives you an ability to add the text which is short and one liner. The best case scenario
to use this field is for Titles, Names where we don’t have styling.
Field type in Template

Field type rendered in item

Code Snippet to render this field type on Front end.

47
The value given in the field

The way it is rendered on Front end

2. Multi-Line Text
This field type gives you an ability to add the text which is more than one line and which don’t use and
styling. The best case scenario to use this field is for Summaries, Short Descriptions where we don’t
have any styling.
Field type in Template

Field type rendered in item

48
Code Snippet to render this field type on Front end.

The way it is rendered on Front end

Field editable in Experience Editor

3. Rich Text
This field type gives you an ability to add the text with rich functionalities to style the content –
making it bold, italics, underlined, adding images, hyperlink, custom HTML, etc. The best case scenario
to use this field is for Descriptions, Blog Content, News Content, etc where we need styling.

49
Field type in Template

There are 4 types of Rich Text editors that we can use in Sitecore - Rich Text Default, Rich Text Full,
Rich Text IDE and Rich Text Medium.
The default one is Rich Text Default and is populated when the Source field is left blank. In case we
need to use the other Rich Text Editor options then we need to mention it in the Source field like
below:
/sitecore/system/Settings/Html Editor Profiles/Rich Text Full

Field type rendered in item

50
We can click on Show Editor and Edit the text or in case we have a HTMl then we can click Edit HTML
and update the HTML.

Save the changes by clicking Accept button in the Editor.


Code Snippet to render this field type on Front end.

The way it is rendered on Front end

51
Field editable in Experience Editor

4. Integer
This field can be used when you need to store a whole number. It is best to use when you want store
Age, etc which needs an integer value.
Field type in Template

Field type rendered in item

In case, we enter anything other than integer value and try to Save then we will get a pop up to enter
a valid integer value.
Code Snippet to render this field type on Front end.

The way it will be rendered on Front End

52
Field editable in Experience Editor

5. Number
This field can be used when you need to store a number which are not sure if it will be an integer or a
fraction value. In case of weight of the products etc which can be decimal or integer in value.
Field type in Template

Field type rendered in item

Code snippet to render field type on the Front end.

The way it will be rendered on Front End

53
Field editable in Experience Editor

6. Password.
As the name suggests, we use this field for Password and Confirm password. The value is hidden and
not shown to the user.
Field type in Template

Field type rendered in item

Code snippet to render field type on the Front end.

54
The way it will be rendered on Front End

Field editable in Experience Editor

7. Date
This field is useful when we want to store only Date. In the cases like Date of Birth, Event Date, News
Published date, etc.
Field type in Template

Field type rendered in item

55
Code snippet to render field type on the Front end.

The way it will be rendered on Front End

Field editable in Experience Editor

8. Datetime
This field is useful when we want to store Date as well as the time. In the cases like last modified,
created date and time, News published time, etc. Item created and updated date and time are stored
in the Standard fields by Sitecore.
Field type in Template

56
Field type rendered in item

Code snippet to render field type on the Front end.

The way it will be rendered on Front End

Field editable in Experience Editor

9. Image
As the name suggests, this field is used for adding the images for a particular page. Be it a banner
image. Thumbnail image, or the profile picture this field will be very handy for you.

57
Field type in Template

The Source field can be used for Image field as well. Here how it can be useful is – if the Source field is
left blank then the whole Media Library is accessible while browsing the image. And if given a path of
folder in a Media Library then only that particular folder is accessible to the content editor.
Create a Test Folder in the media Library.
- Right click on Media Library >> Insert >> Media Folder
- Name it ‘Test’
- Copy the item path (/sitecore/media library/Test)
- Paste this path in our field ‘Thumbnail’.
Field type rendered in item

58
Click on Browse to add an image.

If we check, it opens the Test folder for us. Since we don’t have any image in Test folder, Click Upload
Media in upper left corner and upload a new image.

Click on Select once the image is uploaded.


Code snippet to render field type on the Front end.

59
The way it will be rendered on Front End

60
Field editable in Experience Editor

10. Checkbox
The name itself explains the field’s use. We can use it whenever we need the value in 2 options – True
or False OR 1 or 0. Is Active, Is Press release, Is Media File, Is Product, Is Service can be probable fields
where you can use checkbox. This field cannot be rendered on Experience editor because each field
for which we checkbox have different purposes.

61
Field type in Template

Field type rendered in item

Code snippet to use the field type on the Front end.

The way the code will be rendered on Front End

This covers our basic field types. None of the remaining field types are editable in Experience editor
because it depends on developers what they want to display from the selected items. In case we want
to make it Experience Editor compatible then we can do it using edit frames. This we can learn at later
stages.

11. Checklist

62
This field allows the content editor to select the multiple values from the list of the items. The
selection between the field types Checklist, Multilist, Multilist with Search, Treelist, and TreelistEx,
totally dependents on the developer and client as all the fields provide the same functionality at the
back end but gives different UI to select the multiple values.
I have created a list of Fruits which we will provide as a source to these fields.
Field type in Template

Field type rendered in item

I have selected Apple and Grapes.


Code snippet to use the field type on the Front end.

63
The way the code will be rendered on Front End

12. Droplist
This is one of the options for Drop down features. This field helps you to configure Drop down. The
content editor will be able to select single value from the list of the items. There is one more option
for drop down that can be used is Droplink. The difference between 2 is Droplist saves only the Name
of the item selected whereas the Droplink saves the id of the item selected hence we can retrieve the
item and access all its fields.
Field type in Template

Field type rendered in item

I have selected Guava.


Code snippet to use the field type on the Front end.

64
The way the code will be rendered on Front End

13. Droplink
This field is similar to Droplist, the only difference is the value it stores. This field stores the id of the
selected item and Droplist stores the name of the item selected.
Field type in Template

Field type rendered in item

I have selected Banana.


Code snippet to use the field type on the Front end.

65
The way the code will be rendered on Front End

14. Multilist
This field helps the content editor to select multiple values from the list. It is similar to Checklist but
differs in UI. The backend remains the same. It is useful when we have a large list and check list won’t
be acceptable in the large lists.
Field type in Template

Field type rendered in item

I have selected Banana & Grapes.

66
Code snippet to use the field type on the Front end.

The way the code will be rendered on Front End

15. Multilist with Search


This field is similar to the Multilist but this is more useful as it provides you with the search
functionality which comes handy when you have large set of items. Even the way we fill Source field
for other fields is different than this field. Here the Source field is like a query. We need to have
container id. In our case we need to note down Fruits folder id.
Fruits folder ID - {BE5DD6F8-8BE5-4C87-BF16-7108C34E1F58}
Query - StartSearchLocation={BE5DD6F8-8BE5-4C87-BF16-7108C34E1F58}
Field type in Template

67
Field type rendered in item

I have selected Banana & Grapes.


Code snippet to use the field type on the Front end.

The way the code will be rendered on Front End

16. Treelist/TreelistEx.
This field is useful when you want to allow content editor to select multiple values from the content
tree. We can give home node as a source and then any item under home can be selected. For
simplicity I have given the fruits folder as a source. There is one more field same like Treelist known as
TreelistEx. The difference between these two is Treelist loads the content tree always where as
TreelistEx loads the Content tree on demand. In case the node given by us as Source has too many sub
children then loading it can be expensive operation. So as per our need we should use Treelist or

68
TreeEx. The backend code and Front end display remains the same. Only it’s presentation as a field in
the item differs a bit.
Field type in Template

Field type rendered in item


Treelist

TreelistEx

69
I have selected Banana & Chikoo.
Code snippet to use the field type on the Front end.

The way the code will be rendered on Front End

17. General Link


This field can be handy when you want to redirect user to some other page or window but at the same
time you are not sure whether it will be internal link, external link, mailto function, etc. In this
situation the General Link field is the best option to go with.
Field type in Template

Field type rendered in item

70
Code snippet to use the field type on the Front end.

The way the code will be rendered on Front End

18. Internal Link


This field is similar to the General link but as name suggests, it can be used when you want to redirect
the user with the site. In case you are very sure that content editor will add internal link only then you
can go for this field.
Field type in Template

Field type rendered in item

71
Code snippet to use the field type on the Front end.

The way the code will be rendered on Front End

Here we complete all the normal fields which we generally use to create a Sitecore solution. Any other fields
which are present in Sitecore are rarely used and depend on the Project requirement.

Templates
A template in Sitecore is an item, which defines the structure and behavior of other items. Every item in
Sitecore is an instance of some template. A template may also define the sections and fields into which it
breaks down into and fulfills the content. Each section represents a sub-item under the template and every
field is another sub-item under the item of the related section.

Templates are found in /sitecore/templates

72
Basic Types of Templates

The basic types of templates that can be defined in Content Editor/Template Editor are as below:

Data Templates

Data template defines the data and all the information that you want to display on a page like text, image etc.
Data template is schema for Sitecore content. Any content item in a Sitecore database is based on a data
template. It can contain fields and can be instanced by editors using insert page. Data templates can inherit
from other data templates and can be assigned Presentation Details and insert options.

How to create a Data Template:

1. First navigate to Sitecore/Templates and right click on Templates and click on Template folder -
'Sitecore Demo'.

73
It will create a folder where you can create all your templates.
Best practice: Always create a separate folder for your templates

2. Navigate to the folder you have created (“Sitecore Demo” in my case) and create a new template by
right-clicking on it.

74
3. Give your template a name - 'Dummy Data template'.

75
4. Select the folder you have created and click next.

5. Your template is created.

76
6. Now create section and fields in your template. To do that click on the builder tab of the template and
just input a section name in the textbox.

7. Save the changes.


8. The data template is ready to be used.

Page Template

Page template is a type of Data template which does not have any fields but only inherits the base templates
required for the particular page. In the page templates, the presentation details are configured in it’s standard
values so that every page created from this page template has an uniformity.

Branch Template

A branch template consists of a branch template definition item, which can contain a single item, a hierarchy
of items, or multiple hierarchies of items. It allows you to define the content structure and entire branch of
templates so by creating an instance of a branch template the whole item structure appears without the user
having to create them one by one.

Building the Branch Template-

77
Select the /Sitecore/templates/Branches/User Defined folder in the content tree.

Steps to create Branch Template:

Scenario – Imagine you have to create a structure for an every page you create. Carousal Images and Files as
folders needs to be created below each every page you create. In this scenario branch template becomes
handy. Whenever you create an item based on this branch template, it will create a predefined structure for
you.

Let’s get started-

1. At first navigate to “/sitecore/templates/Sitecore Demo” create a template which is the base for
branch template.

78
2. Create 2 more templates – Image Carousal, Files folder.

3. Now, navigate to /Sitecore/Templates/Branches/User Defined and create a folder for your site
(Sitecore Demo). – Right Click >> Insert >> Branch Folder

79
4. Now right click on the folder you created and click New Branch. – Right Click >> Insert >> New
Branch

5. Select the base template you created for your branch template.
Note – Base template give you the same name to your branch template, you can rename it by

80
right-clicking on it.

6. I have renamed the new branch template to ‘Page’.


7. A new branch template item will have been created including a Website item named $name
$name is a template token that will be replaced with the selected name when the branch
template is used. A Sitecore token is way to have a field value dynamically resolved during item
creation.
8. Right click on $name token and click on insert from template to create branch template.

81
9. Select the Image carousal template created earlier.

10. Repeat the steps 8 & 9 to add the Files folder template.
11. Select the base template you created for your branch template, give it a name and click Insert.

12. Now navigate to Sitecore/Content/Home and right click on Home item and click insert from
template.

82
13. Select the branch template you created (/Branches/User Defined/Sitecore Demo/Page), give it a
name and click insert.

14. Now your complete structure created under Home item.

Rendering Parameter template

83
Rendering parameter template is defined for displaying or presenting the data on a page. Rendering
parameters can be used to pass parameters to Sitecore presentation components. They are used to control
the presentation of a dynamic component from experience editor.

Rendering Parameter Templates, which allow the template author to specify named parameters which will
appear in the dialogue used to configure presentation component properties and the data type of these
parameters.

Let’s get started with rendering parameter templates:

It’s a two-step process, so first you create rendering parameter template itself and second you attach it to
rendering.

1. First navigate to Sitecore /sitecore/templates/Sitecore Demo and create a rendering template.


2. Right click on Sitecore Demo >> Insert >> Insert from template

3. Give your template a name and change the base template from Standard Template to Standard
Rendering Parameters (Templates/System/Layout/Rendering Parameters/Standard Rendering

84
Parameters) and click Insert.

4. Select the folder you created for your template and click Next.
5. Create sections and fields according to your requirement.

85
6. Now navigate to rendering (Create a dummy Rendering – View Rendering) for which you want to
use rendering parameter.

7. Search for the Parameter Template field and attach it to rendering parameter template you
created.

8. Select the new parameter template created.

9. Click Save.
10. Open the presentation details of the item from the ribbon.

86
11. Open the rendering and you can see your parameters are showing on the rendering.

Command templates

Command templates allows insert of items according to logic rather than predefined structures.

Unlike data templates and branch templates, which consist of predefined structures, command templates
reference Sitecore UI commands to invoke wizards or other logic used to create new items.

All other template categories contain a predefined structure. But what if you need to write some dynamic
logic to create items, for this we use Command templates.

Command template defines a class and method to be called during an insert operation. Whenever we try to
create an item from this template, associate class method would be executed.

87
We can create a command template, using /System/Branches/Command Template.

How to start with command template-

1. Create templates with required fields.


2. Create a class that inherits from Sitecore.Shell.Framework.Commands.Command, and override the
Execute () method.
3. Add a /configuration/command element to the file /App_Config/Commands.config.
4. Insert a command template definition item using /System/Branches/Command Template data
template.
5. In the command template definition item, in the Data section, for the Command field, enter the
command code.
6. Assign this command template to standard values of the template insert option created in step1.

Template inheritance
Templates can inherit from one or more other templates. Thanks to inheritance, we can define abstract
templates commonly to more data templates. Thanks to this, content items can contain a number of fields
without always having to re-define them separately for every template.

Standard template

Standard template is a basic template, which Sitecore provides for its function. This template does not contain
any fields but it inherits from a number of other templates thanks to which we are able to define the display
name, layout details, publishing restrictions and workflow, etc. on the items. All of the fields inherited into
standard template begin with__.

88
The standard template is found in /Sitecore/templates/System/Templates/Standard template

Let’s inherit one template into another.

1. If you remember, we have created one template Dummy Data template with fields – Title, Description
and Image.
2. Now assume that you have to create a template with fields Title, Summary, Description, Image and
Contact Number.
3. Instead of creating a new template with 5 fields – you can create a new template with 2 fields and
inherit the Dummy Data template in the new one.
4. Create new template – Dummy Derived Template

5. Now lets inherit the Dummy Data template.

89
6. Switch to Content Node. Add double click on Dummy Data template in the left column.

7. Save the changes.


8. Let’s create a new item based on this template.
9. Navigate to /sitecore/content/Home and right click >> Insert >> Insert from template

10. If you see the fields – 2 sections are present (Basic Details & Details) these are fields derived from
Dummy Data template and Dummy Derived template.

90
It is recommended that we use as much as template inheritance while planning an Information Architecture of
the Website. This will help you in future in case you need to change the field type or any standard values for a
particular template.

Standard values
Apart from the fields, the template may also contain layout details defining preview, insert options defining
hierarchal templates for creating initial values, including the use of tokens as for example, $name or for
example, icons. However, not all these settings will transfer onto the item when creating an instance template.
For this purpose, it is necessary to create a special type of item, __Standard Values, under the template. It
basically deals with an instance template, which defines the values of the fields, including fields from the
Standard template, which are not defined on the instance template. They are common for all items created
from the same template. Therefore, until the content item has its own defined value of some field, the value
from the __Standard Values is used.

You can create __Standard Values using the Standard values button in the Ribbon on the Builder Options tab.
In order for the Builder Options tab to appear, you have to choose a template from the branch in the left part
of the window and switch over to the Builder tab in the content part of the window.

Let’s create some standard values for Dummy Data Template:

1. Navigate to the template (/sitecore/templates/Sitecore Demo/Dummy Data template)


2. Click on Builder Options >> Click on Standard values

3. The __Standard Values item will be created under the Dummy Data template.
4. Now we will use tokens for defining the default values for the field while creating an item.
5. So Sitecore provides out of the box tokens that can be used namely $name, $parentname, $id,
$parentid, $date, $time and $datetime.

91
6. Lets use $name in title field and use plain text in Description field.

7. Let’s configure an icon as well for this template.


8. Be on __Standard Values item >> Configure tab >> Icon dropdown button.

9. Save the changes.


10. Lets try to create the item based on this template.

92
11. Navigate to /sitecore/content/Home/Test Branch item/Files Folder item.
12. Right click >> Insert >> Insert from template.
13. Select the Dummy Data template and Name it – “Testing Standard Values”.

14. You can see that title field auto populated the name we gave to create the item. Also the icon is
present on the newly created item.
15. Now lets discuss on the Insert options. Since we are logged in as admin user, we are getting an option
to insert from template. If a non admin user wants to create an item and if insert options are not set
then s/he will not be able to create one.
16. Let’s set insert options for Files folder template.
17. Navigate to /sitecore/templates/Sitecore Demo/Files Folder.

93
18. Click on Builder Options tab and Click on Standard Values.

19. Go to View tab and check Standard Fields.

20. Scroll Down to Insert Options section.

94
21. Click Edit button under Insert Options field.

22. Select Dummy Data template and Click OK.

23. Navigate to the Files Folder item under Home node (/sitecore/content/Home/Test Branch item/Files
Folder).

95
24. Right Click >> Insert. Now you will see an option to add items based on Dummy Data template directly.

25. This is recommended to be done while designing the Information Architecture so that the Content
Editor without admin access don’t face any issues.
26. We can also assign Presentation details and Workflows in the Standard Values. We will explain it in
those particular topics.

Media Library
You can manage all your media items from the Media Library, such as images that you want to embed in a
webpage or make available for download by visitors. The Media Library contains all you media items, such as
images, documents, videos, and audio files.

In the Media Library you can:

96
1. Keep all your media files in one place and organize them in a folder structure similar to the
content tree.
2. Navigate the content tree or use Sitecore’s search functionality to quickly find media items.
3. Upload media files to the Media Library. You can use the upload buttons to browse your computer
for images or simply use the Drag & Drop dialog box to add media files.
4. Make every media content item and media file versionable.

Let’s add one image in the media library and try to use it in an item.

1. We should always create our Website folder in the Media Library.


2. Once the website folder is created, we should have sub folders logically designed such as media files
related to News will go in News folder, media related to Blogs will go in Blogs folder, Images related to
About page will go in About folder, etc.
3. Create a Media folder with name Sitecore Demo.
4. Click on Media Library >> Insert >> Media folder

5. Similarly create a test folder under the Sitecore Demo folder

6. Lets upload an image under this folder.


7. Click Upload file.

97
8. Choose file and click Upload.

9. Go to Content Editor.
10. Navigate to the Path (/sitecore/content/Home/Test Branch item/Files Folder/Testing Standard Values)
11. Click Browse under Image field.

12. Click Select.

98
13. Save the changes. This is how we can upload the item and then use it in the items.

Layouts
Layouts
Layouts are the scaffolding for your web pages, and will usually include the <head> and <body> tags for the
markup. They often pull in styling and JavaScript code but have little markup themselves, instead it have
multiple placeholders in which one can plug component renderings.

All the layouts reside at /sitecore/layout/Layouts

99
There are a few ways to create a new layout in Sitecore. The first way would be inside the instance. Simply
navigate to the content editor, then to the Layout section. Expand this section and open the “Layouts” section
inside. Create or navigate to a folder here and right-click the folder to add a new Layout item. You’ll need to
provide a path to a corresponding razor view (.cshtml) file, which you should create in a project somewhere in
your solution.

Let’s create one layout in Visual Studio and then create the same in Sitecore.

1. In the Views folder, add a View – Main.cshtml

100
2. Enter the HTML whatever you wish to – It should whole HTML (Head + Body).

101
3. Publish the View.

4. Note the path of the Main.chtml file – (/Views/Main.cshtml)


5. Now go to Content Editor and navigate to Layouts (/sitecore/layout/Layouts).
6. Right Click >> Insert >> Layout

102
7. Name it – Main Layout and select the Locations as Layouts.

8. Change the value in the path field to “/Views/Main.cshtml”

9. Publish the layout.

10. Now we are ready with the layout. Let’s assign it to one of the Item and check.
11. Navigate to “/sitecore/content/Home/Test Item”.

103
12. Click on Presentation Tab >> Details.

13. Click Edit in Layout Details pop up.

104
14. Select the Main Layout and Click OK.

15. Again click OK and Publish the Test Item.


16. Now browse http://sitecoredemo.sc/test-item

17. This is how we create the layouts. It is recommended that we shouldn’t have more than one layout
per device. Maximum 2 are allowed in case we are giving an option for end user to print the web page.

To create a new layout through Sitecore Rocks:

105
1. Right-click a "Views" folder in your visual studio project (in the VS solution explorer, NOT the Sitecore
Explorer).
2. Choose Add -> New item...

3. Select Sitecore -> MVC -> Sitecore View Layout.

106
4. If the layout is created successfully and if your project is correctly connected to the Sitecore instance,
Sitecore Rocks will ask you to create an item in the Sitecore Content Tree. Add the layout item in the
Layouts folder (sitecore/layout/Layouts) in Master DB. This process will also automatically create a
view file to link to the layout item.

107
5. The layout is successfully created.

6. Publish this view and Publish the layout item from the Sitecore. And you can use the layout.

If you do encounter an error when creating a layout, please refer to our "Error when creating a Layout -
TemplateWizard" article.

Now that the layout is created, it can be used to display content. Layouts don’t have code-behinds with the
ability to execute business logic, which is what renderings are for. However, any item in your content tree can
be given a corresponding layout, and that layout can display that item’s information through the use of field
renderers (like @Html.Sitecore().Fields(“title”)).

Renderings

In Sitecore CMS, every web page is split into multiple pieces/blocks and each of these blocks is
rendered/presented by different components (a piece of functionality) separately. Every component is defined
with a specific purpose and functionality.

For example a basic web page can have a header, a footer and page body. In this case, we might have a header
component, footer component, page body component

108
Now, each of these components requires some logic to present the right content in each of these sections
dynamically. This logic which could generate a piece of html dynamically is nothing but a rendering in Sitecore.
Once all the renderings are rendered in page, the complete html of the page is generated and could display
the web page as required.

In Sitecore MVC, each rendering is nothing but a controller action or even it could be a simple view.

Before jumping to how to create a rendering, let us discuss how it can be rendered and which the commonly
used renderings are. To answer this, we use 2 types of renderings commonly – View Rendering and Controller
Rendering.

View Rendering is used when we don’t have much business logic to be executed. Controller rendering is used
when we have business logic to be executed.

The renderings can be assigned to a layout statically or dynamically. We can statically bind the
components/renderings to the layout when we are sure that its place will not change at any given time ex.
Header and Footer. When we are not sure about the placing of the components ex. Main body components
then we go for dynamic bindings also known as Placeholders.

So to create a View rendering in Sitecore

109
1. Create a partial view in a Visual Studio.

2. Add any HTML which can make you understand that the view rendering is rendered on Front end.

3. Publish this View.

4. Go to Content Editor and navigate to Renderings (/sitecore/layout/Renderings).

110
5. Right Click >> Insert >> View Rendering.

6. Name it View rendering and add the Path of the View which we created
(/Views/ViewRendering.cshtml).

7. Publish this rendering and note it’s ID.

8. Let’s statically bind this View Rendering in the Layout we created earlier.

111
9. Add code ‘@Html.Sitecore().Rendering("{275115AB-C60F-4FC8-ADC5-A5D5F381BF5D}")’ in
Main.cshtml – the Layout.

10. Publish this view and Browse http://sitecoredemo.sc/test-item

11. This means our View rendering is rendered successfully on the Layout. So we learnt about creating a
View rendering and statically binding it to the layout. Now let’s learn about Controller rendering and
dynamically binding it to the layout.

To create a Controller rendering in Sitecore

1. Let’ create a Controller in Visual Studio and write one Action method.

2. If you remember we have one Fruits folder in Sitecore, so we will create a Controller rendering to
display all the fruits on the page.

3. Click on Controller Folder and Click on Add >> Controller.

112
4. MVC 5 Controller – Empty.

5. Name it “ControllerRendering”.

6. The body of the Controller looks something like this.

7. Now let’s add the Sitecore namespaces and code to fetch the Fruits folder in the business logic.

113
8. Now we need to create a View for this controller.

9. Hover over the method and right Click >> Add View.

114
10. Let the name be Index and it be partial View. Click Add.

11. The body of the View should be to read the list of Fruit and display them.

115
12. Now let’s publish the whole solution as the code behind in involved. Right Click on Solution >> Publish.

13. Once the publish task is completed. Reload the Sitecore and go to the Content Editor.

14. Navigate to the Renderings ((/sitecore/layout/Renderings).

15. Right Click >> Insert >> Controller rendering.

16. Let the name be Controller rendering.

116
17. Enter the value for Controller and Action Fields.

18. Publish the Rendering.

19. Let’s dynamically bind this rendering to the Main Layout.

20. Add this code ‘@Html.Sitecore().Placeholder("main")’ in Main Layout.

21. Publish the Main.cshtml

22. Go to the Test Item in Sitecore (/sitecore/content/Home/Test Item)

117
23. Click on Presentation tab >> Details.

24. Click on Edit link the pop up.

118
25. Click on the Controls tab in the left.

26. Click on Add button in the right.

27. Select the ‘Controller rendering’ which we created and in Add to Placeholder textbox, write ‘main’ as
we have set ‘main’ as key in our Main layout - ‘ @Html.Sitecore().Placeholder("main")’

28. Click Select >> Click OK >> Click OK.

29. Save the Changes and Publish the Test Item.

119
30. Now Browse http://sitecoredemo.sc/test-item

So we learnt about View Rendering and Controller rendering and how to assign them to Layout based on
statically and dynamically bindings. For statically binding we need the ID of the Rendering we create and For
dynamically binding we use the placeholder keys.

Placeholders
Placeholders in Sitecore allow the dynamic assembly of page layouts either by allowing the editors to design
specific pages, or by allowing administrators to create predefined variations of layouts on Page Type
templates. Most often, placeholders are contained in the layouts and sub-layouts in the Project layer modules.
In rare cases renderings in feature or foundation modules can contain placeholders, for example when dealing
with elastic or composite page components such as tabs, accordions, carousels etc.

The actual conventions for placeholders and placeholder definitions are very project specific, as they affect the
dynamic page layouts (which renderings can go where on the page) and the visual design of the pages (how
will renderings change appearance based on where they are placed).

Keep in mind that placeholders are not only used by editors to dynamically design pages, but also allow
developers to create variations of pages merely by reconfiguring a Page Type template. Therefore you should
favor the dynamic constructing the page layout with many placeholders and renderings, but ensure that you
keep a consistent visual design and coherent user experience by controlling the page layout editing with
security or by marking placeholders as non-editable. This practice will greatly increase the flexibility and
simplicity of creating new page types and layouts as it reduces the need for development.

Now we will understand why we need placeholders and placeholder settings.

120
If we don’t use the placeholder then each component we need to statically bind to the Layout. If this is a case
then the flexibility to change the page design with minimal efforts is lost. So we are using placeholders to
dynamically bind the components/renderings to the layout as we saw in the Controller rendering. Now you
will have a doubt that we did dynamic binding then why we need placeholder settings.

Let’s understand this in detail. Now you as a developer have setup Controller rendering using a placeholder
key ‘main’. When the content Editor is trying to edit (Remove the rendering) it in Experience editor, s/he is not
allowed and dependency comes back to you. To remove this dependency, we need to create placeholder
settings so that content editors can make a full use of the experience editor.

Let’s examine the scenario we discussed.

1. Go to the Test Item (/sitecore/content/Home/Test Item).


2. Click on Publish tab >> Experience editor.

3. There is no placeholder setting for ‘main’ is present.

121
4. Click on View tab >> uncheck Editing >> Check Designing checkbox.

5. Now hover on the Controller rendering part and click on it.

122
6. If you see most of the options are disabled. To enable these options we will need to create main
placeholder setting.
7. Go to the Content editor tab.
8. Navigate to Placeholder settings (/sitecore/layout/Placeholder Settings).

9. Right Click >> Insert >> Placeholder

10. Name it ‘main’ and Click OK.


11. Reload the Experience editor. Hover on Controller rendering part and click on it.

123
12. Now the options are enabled. Click on the Delete option and delete the rendering.

13. Now if you again click in the area of the component. You will see an Add here option. Click on that
button.

14. It gives us an ability to add any rendering. This can be the possibility of error as the content editors will
not be familiar which one to be used. So we need to give them only few no. options to be used in one
placeholder.
15. Again switch to Content Editor. Navigate to main placeholder setting. (/sitecore/layout/Placeholder
Settings/main)

124
16. Click Edit under Allowed Controls field (second field).

17. Select Controller rendering and View rendering in the pop up.

18. Click Ok. Save the changes.


19. Reload the Experience Editor.

125
20. Click on Add here button. Now you will be able to see only 2 options. This minimizes the error that
content editor can cause.

21. Select any of the component/rendering you wish to assign and click Select.
22. Save the changes. Publish Test item.

126
23. Browse http://sitecoredemo.sc/test-item

This completes the placeholders and placeholder settings. There is one more concept of dynamic
placeholders that we will go through now. Till now we have learnt Static binding, Dynamic binding,
Placeholders, and Placeholder settings. The placeholders which we learnt can be known as Static
placeholders as the key will remain same at any given time.

Dynamic Placeholders come handy when you need repetition of data or placeholders. Let’s consider you
have one placeholder ‘main’ in the layout. Then to distinguish the page types you have one-col, two-col
and three-col renderings. And then finally you have the components/renderings which will fit in the
content – let’s use the same ones which we created Controller rendering (List of Fruits) and View
rendering (static text). Now we want the structure like below:

Main

- one column

- Controller Rendering

- one column

- View Rendering

Let’s check if the above scenario is possible using static placeholders.

127
1. Go to Main layout in Visual Studio and comment the static binding.

2. Publish Main.cshtml.
3. Create new View – name it OneColumn.cshtml and place the code
‘@Html.Sitecore().Placeholder("section")’ in it.

4. Publish OneColumn.cshtml.
5. Go to Content Editor and Navigate to the Renderings (/sitecore/layout/Renderings).
6. Right Click >> Insert >> View rendering.

128
7. Name it One column and Click OK. Add the path of the recently created View.

8. Save the changes. Publish the rendering.


9. Navigate to Main placeholder settings (/sitecore/layout/Placeholder Settings/main).
10. Remove Controller rendering and View rendering from the Allowed components and Add One column.

129
11. Create new placeholder settings with name ‘section’ and add Controller rendering and View rendering
in it’s Allowed Controls.

12. Publish both the placeholder settings.


13. Navigate to Test Item. Click on Publish tab and Click on Experience Editor.
14. Delete any renderings if any. So the experience editor will look like:

15. Click on the center of the box >> Add here >> Click on One Column.

130
16. Again click on the center of the box >> Add here >> Click on Controller rendering.

17. Click on dropdown button next to tree structure which shows the hierarchies of the placeholders
used.

18. Now we have achieved the below structure.

Main

- one column

- Controller Rendering

131
19. To achieve the remaining, we will click on the main placeholder from the tree.

20. Now again you will be able to see Add here buttons at the top and bottom of the box.

21. Click on the below Add here button >> One Column.

132
22. Add now you will see that we didn’t get option to select the View rendering and data just got
duplicated.

23. This is where Dynamic placeholders are very useful.


24. Delete the second rendering and Save the changes.
25. Open Main.cshtml in the Visual studio. Change the placeholder code to
‘@Html.Sitecore().DynamicPlaceholder("main")’

133
26. Open OneColumn.cshtml and change the code to
‘@Html.Sitecore().DynamicPlaceholder("section")’

27. Publish both the cshtmls.


28. Reload the Experience Editor.
29. Delete all the renderings. May be you can switch to Content editor.
30. Go to The presentation details >> Controls. And remove all the controls.

31. Click OK and publish the test item.

134
32. Switch to experience editor. Click in the section.

33. Click on Add here >> One Column.


34. Again click in the middle >> Add here >> Controller Rendering.

135
35. Click on Main >> Lower Add here button >> One Column.

36. Now the data didn’t get duplicated as we used dynamic placeholders.
37. You click on Add here and select the View rendering.

136
38. Publish the item >> Home tab >> Publish button in the upper right corner.
39. Browse http://sitecoredemo.sc/test-item

40. This completes Dynamic placeholders. So in case you have requirements where you feel the
renderings can be reused then we need to use Dynamic renderings. There are certain limitations of
using dynamic placeholders that you can read here.

Datasources
Datasources are used for various reasons and at various places. There are mainly 2 types of Data sources.

Field Datasources
These Datasources are one we discussed while discussing the field types. In the templates area each field type
has a text box as Source. Some field types require a value in it and some don’t require. All the fields that
display a list of items for the selection are using field Datasources.

137
These types of Datasources are known as Field Datasources and are widely used.

Rendering Datasources
This type of Datasources we have not yet discussed in our document. We will go through it but before that
let’s discuss a scenario where this datasource will be every useful for us.

Let’s consider we need to use the list of fruits at various places in our website. So creating those many copies
of fruits folder is possible but how we will manage any modifications in it? So in this case we keep it at central
location and pass it to the page as a datasource in a particular rendering. Secondly if we are hardcoding the
logic of fetching the fruits then we will not be able to personalize the content based on the Personalization
rules. So instead of hardcoding the logic, we should read the datasource and display the content.

Let’s use the rendering datasource to display the list of fruits in the Controller Rendering instead of
Hardcoding it.

1. Go to Visual Studio.
2. Open ControllerRendering controller.
3. Modify the code to fetch the list from datasource and not directly from the item.

4. Comment the previous logic. And add the new logic.


5. Publish the Solution since there is code behind changes.
6. Go to Sitecore and Open Content Editor.
7. Navigate to the Test Item.

138
8. Click on Presentation tab >> Details.

139
9. Click on Final Rendering >> Controller rendering.

140
10. Click Browse under Datasource field and select the Fruits folder.

11. Click OK and publish the Test Item.

141
12. Browse http://sitecoredemo.sc/test-item

13. The front end remains the same but now the content editor can select the folder from Sitecore itself
and the data will be displayed based on the datasource provided.

The rendering datasource can be defined at 3 locations – On item’s rendering (the one we did), Templates
Standard Value’s rendering and at the Rendering. Since we can define at 3 locations, it has fallback
mechanism. First it checks for Item’s rendering datasource >> Standard Value’s rendering datasource >>
Rendering. If none of these 3 has datasource value then it will be blank displayed on Front end.

Let’s see how we can quickly change the content using datasource without any code changes. We will
display the list of Colors instead of Fruits.

142
1. Go to Sitecore >> Content Editor >> Test Item >> Launch Experience Editor.

2. Go to View >> Check Designing checkbox. Click on Controller Rendering part.


3. Click on the drop down arrow on the 5 th option >> Change associated content.

143
4. By default fruits folder will be selected as it is our current datasource. Select Color folder and click OK.

5. And the content is changed.

144
6. This is the power of Rendering Datasource. It is highly recommended to use as much as datasources as
possible so that you can personalize your website based on it.

Now since the content editors have the ability to choose the datasource, it increases the chances of error. To
minimize the error, we should restrict or narrow down the available selections.

1. Go to Content Editor and Navigate to Controller rendering (/sitecore/layout/Renderings/Controller


rendering)
2. Scroll down To Editor Options section and find the field ‘Datasource Template’.
3. Click Insert link.

4. Select Folder template as we select folders as our datasources in our examples.

5. Click Insert. Save the changes.

145
6. Switch to Experience Editor and Reload it.
7. Click on Controller rendering area >> Click dropdown arrow next to the 5 th option >> Change
associated content.
8. By default Color folder is selected as it is our datasource. Click on any other item which is not a folder.

9. From the above image, you can see that an error message is displayed to the Content Editor and OK
button is disabled. This reduces the error of selecting the wrong datasources.
10. If you select any of the folders (Color, CssClass and Fruits), you will be allowed to select it as a
datasource.

Miscellaneous
Multi-Site
Sitecore provides multi-site as an out of the box feature. We can use this feature in case our client has number
of sites and s/he is willing to have all on Sitecore then using one Sitecore license, we can configure all these
sites with minimal efforts.

We will create one more site and will name it as ‘local.sitecore92.com’.

Creating a new site in Sitecore instance (e.g. http:// local.sitecore92.com) involves three step process:

Step-1:

146
Configure your site hostname in Sitecore Instance. There are two ways to add new site in your Sitecore
instance.

1) Add <site> element under <sites> section in sitecore.config file


(C:\inetpub\wwwroot\SitecoreDemo.sc\App_Config\Sitecore.config)

2) Add <site> element under <sites> section in SiteDefintion.config file

You will find SiteDefintion.config.example file at


C:\inetpub\wwwroot\SitecoreDemo.sc\App_Config\Include\Examples\.
You need to copy this file in the Include folder and remove the .example extension in order to use.

147
Now you may be wondering which one is good option. It is good to add new site in SiteDefinition.config file
because it’s always advisable not to touch default config files and override your custom settings in config files
situated under App_Config folder provided by Sitecore.

After adding new site in config file, there are two more steps need to be performed out of Sitecore to access
newly added site.

Step-2:

Add your site hostname in IIS binding

Step-3:

Add your site hostname in hosts file (under WINDOWS\System32\drivers\etc\ folder)

148
After completing these three steps your newly added Sitecore website is ready to access.

Multi-lingual
Like multi-site is an out of the box feature, multi-lingual is also one of it. This is very handy when you have to
create a site in different languages. Here also you can set up multi lingual site with minimal efforts.

Let’s see a demo; we will add Spanish as an additional language.

1. Go to Sitecore >> Content Editor.


2. Navigate to Languages (/sitecore/system/Languages)
3. Right Click >> Insert >> Language.

4. Click on the drop down and select Spanish from Spain language.

149
5. Click Next >> Next >>Next >> Close.

6. Publish this language.


7. Navigate to the Home item (/sitecore/content/Home)

150
8. Click on Language version button >> Click on Spanish option language.

9. Click on Add new version.

10. Enter the data in Title and Text field.

151
11. Publish the Home item. Remember to check if the Spanish checkbox is checked.

12. Once the publish operation is completed.

152
13. Browse http://sitecoredemo.sc/

153
14. Now to browse Spanish site, http://sitecoredemo.sc/es-ES

Our multi-lingual setup is done, it is very simple and with no code involved. There are couple of things we
need to understand are how the language read by Sitecore to change the content.

1. Sitecore looks for language query string (?sc_lang=en)


2. Language embedded in the URL (http://sitecoredemo.sc/es-ES)
3. If both the above are missing then it checks for Language cookie managed by Sitecore for the context
language.

Recommended and SEO friendly is the second approach to embed the language in the URL. We need to design
the language selector module that can be part of Header which will give your end users an idea that the
website is multi lingual and they can access the site in whichever language they wish to.

Buckets
Buckets is also one of the out-of-the-box features from Sitecore. There is limitation on the number of sub child
for an item in Sitecore. If the # of sub children are greater than 100 than the performance is drastically
decreased. To overcome this limitation, we use the concepts of buckets.

Let’s discuss a scenario where the sub children will be greater than 100. Imagine you launched a website
which has a News module. There 5-10 news under News item. Every week we publish 2-3 news. So after 10
months, you will eventually cross the number 100. But now what can you do in this case? Remove News item?
No, we will use bucketing concept here. This is mostly used in News and Blogs modules because over the
period of item, we keep on piling the items in these modules.

154
What is a bucket?

A bucket is a special type of item in Sitecore that acts as a container for other items.

Most importantly, the underlying structure of items inside a bucket does not matter to the user. Items in a
bucket are not displayed in the content tree - instead, users find these items by using Sitecore search.

When to Use a Bucket?

Buckets are useful when any of the following are true:

 Tree structure isn't important. Not all content needs to be organized into an orderly tree structure.
Thousands of content items that are easily and uniquely identified by name or description can benefit
from being in a bucket.
 There are more than 100 items under one node. Sitecore's UI starts to have minor performance issues
when displaying more than 100 items under a tree node. Buckets can support millions of items.
 Searching for content is preferred. With a performant and robust search engine behind Sitecore (Solr,
Coveo, etc.), searching for content can be significantly quicker than digging through a content tree.

Because buckets rely on the Sitecore Content Search API, they will not work if no search indexing engine is
running. Out of the box, all modern versions (9+) of Sitecore support Solr for basic search functionality, so
buckets should always work.

Let’s see how can we configure buckets, the Scenario will be we will have a News listing item and then News
item will be bucketed under it as the news will keep on piling.

1. Go to Sitecore (http://sitecoredemo.sc/sitecore)
2. Enter the credentials (admin/b)
3. Go to Content Editor and Navigate to Website templates folder (/sitecore/templates/Sitecore Demo)
4. Create a template – News template.
5. Right click on Sitecore Demo >> Insert >> New template
6. Name it ‘News template’ >> Next >> Next >> Close.

155
7. Enter the fields required for the News item.

8. Click on Builder Options tab >> Standard Values.

156
9. Enter $name token in Title field and ‘Enter the highlight of the news here...’ in Summary field.

10. Click on Configure tab >> Icons (Down Arrow) >> Select Icon.

11. Save the changes and publish the News template.


12. Click on Sitecore Demo folder >> Insert >> New template
13. Name it ‘News listing template’ >> Next >> Next >> Close.
14. Click on Builders Options tab >> Standard values.
15. Click on View tab >> Check standard fields checkbox.
16. Click on Edit link under Insert Options field under Insert Options section.

157
17. Select News template.

18. Click OK.


19. Click on Configure tab >> Icons (down arrow) >> Select the icon.

20. Publish the News listing template.


21. So these steps were normal and we created 2 templates based on which we will create our items.
22. Now we need to configure bucketing.
23. Navigate to __Standard Values item under News template (/sitecore/templates/Sitecore Demo/News
template/__Standard Values).
24. Go to Item Buckets section.

158
25. And check the Bucketable checkbox. This means that any item based on this template will be under
buckets.

26. Save the changes and publish the template.


27. Navigate to the Home item (/sitecore/content/Home).
28. Right Click >> Insert >> Insert from template.
29. Select the News listing template and Name it “News”.

30. Click Insert.


31. Right Click on News item >> Insert >> News template.

159
32. Name it – “Test News 1”.
33. Similarly add 2-3 more News.
34. So the structure will be similar to the below:

35. In case the News item keep on adding then it will cross 100 count mark and performance will be a
concern. So let’s activate the buckets.
36. Click on News item.
37. Click on Configure tab >> Click on Bucket.

38. Click OK on the pop-up.


39. Now the buckets are active and you will see the structure like this.

160
40. We can find the items in Search tab available at the right console after clicking on News item.

41. In case we want to see the tree below News item then we see it but we should remember to hide it.
42. Click on View tab >> Check the Buckets checkbox.

161
43. And the structure looks something like this:

44. The bucketing concept makes sure that every item goes in different tree structure based on its
creation date and time.
45. Once you have verified the changes, remember to uncheck the buckets checkbox under View tab.

This is highly recommended wherever we know the sub child count will go above 100. And this helps to
upgrade the performance.

Compatible Renderings
What are Compatible Renderings?
A Compatible Rendering is simply a component that can be replaced with another component provided both
use the same datasource type (or no datasource at all); e.g. use the same type of data.

Why use Compatible Renderings?


Compatible renderings allow you to achieve the following:

 Data reuse – less time required for development


 Renderings can have multiple compatible renderings – lots of vibrant ways to display the content
 Editors can change the design of the page whilst using the same content – in a few clicks!
 Displaying the same data to a user in a new way, perhaps to draw their attention for a Call to Action

Compatible Renderings are one of the many great features Sitecore offers; they’re so easy to set up, require
no additional code / development and they’re nice quick wins in any project!

How to Set Up Compatible Renderings

Compatible renderings are pretty straightforward;

1. In the Content Editor, navigate to the rendering or sublayout; for example


/sitecore/layout/Renderings/Controller rendering

162
2. Click on the book icon

3. From the dropdown select Compatible Renderings

163
4. Using the multilist field, select the rendering or sublayout you wish to make compatible with this one
(View rendering in our case.)

5. To confirm its set up, navigate to the Test Item (/sitecore/content/Home/Test Item)
6. Open the Experience Editor, click on the Controller rendering & you should see recycle icon on the
toolbar.

7. In the pop up, you will get the View rendering which we had selected.

8. Click on Select and the View rendering will be applied.

164
9. Now there will be no recycle sign on the View Rendering because we have not set up Compatible
rendering for View rendering.

That’s it! We now have learnt how to set up a compatible rendering for any particular component. You can
have any number of Compatible Renderings for a rendering/component.

Workflows
Workflow is also out-of-the-box feature from the Sitecore. A workflow is a series of predefined states that
reflect the work processes and procedures for creating web content in your organization. For example, your
workflow states could correspond to the creation, review, and approval stages that items must go through
before they are published on your website.

Workflows enable you to have control over the content approval and publishing process, ensuring that only
content that has been approved is published.

Workflows consist of three elements – states, commands and actions.

A workflow can contain any number of workflow states and be as simple or complex as required. Items do not
necessarily have to move through all the workflow states that you have defined. Some states can be optional
or only applicable to certain kinds of content.

The Workbox is a tool in Sitecore that displays information about the items in a workflow such as editing
history or the number of items that you can find in each workflow state. In the Workbox you can find all items
in a workflow.

Let’s understand the Sample workflow present in Sitecore and how it is assigned to Sample item template.

1. Go to Sitecore and Open Content Editor.

165
2. Navigate to Sample Workflow (/sitecore/system/Workflows/Sample Workflow).

3. So as we know that workflow is based on – States, Commands and Action. And very importantly the
name of the workflow.
4. In this case the name of the workflow is Sample Workflow and there are 3 states namely Draft,
Awaiting Approval and Approved.
5. Draft state – This is an initial state of the workflow.

166
6. It is mandatory to set the initial and final state of the workflow, without which your workflow is not
complete.
7. In The Draft state, we have 2 commands – Submit and _OnSave. Basically the commands are 2 take
the content in workflow from one state to another.
8. In this logic, when the Submit command under Draft state is triggered, it will pass the content to
Awaiting Approval state because the next state is configured as “Awaiting Approval”.

9. Similarly if we trigger _OnSave command then the content will be maintained in Draft state because
the next state is configured as “Draft”.

167
10. There is one action under _OnSave command - Auto Submit Action, which calls Sitecore libraries to
pass the content to the Awaiting Approval State as the next state is configured.

11. The commands are mandatory for the initial and intermediate states, depends on the requirement the
actions are configured.
12. Now comes the intermediate state – Awaiting Approval, this state has 3 commands in total.
13. If the Reject command is triggered, then the content will be again passed to Draft.

168
14. If the Approve state is triggered, then the Validation Action will be called and if the content is ok after
validation then the content will be passed to final state i.e. Approved.

15. If the Approve with Test is triggered then the Validation action will be called, once the content is
validated, the A/B test will be created based on the content and then it will be passed to the Final
state.

169
16. Once the content is in final state, the primary requirement of the content editors is that the content
should be published. So this sample workflow has auto publish action.

17. The parameters in the Auto Publish action “deep=1&smart=1” means publish the item with its sub
child and the publishing method will be Smart publish.

170
This is the sample workflow we have in Sitecore; we can create our customized workflow as well. The
minimum requirement is the workflow should have 2 states – initial and a final state.

Now we will check how the workflow is assigned to the Standard values of the templates so that all the items
based on that particular template will be in workflow.

1. Navigate to __Standard values under Sample Item template (/sitecore/templates/Sample/Sample


Item/__Standard Values).

2. Make sure the standard field checkbox is checked under View tab.

3. Go to Workflows section at the end.

4. From the above image we understand the Sample item template has assigned Sample workflow to its
standard value. So all the items based on Sample item template will go through the Sample workflow.

5. Let’s create one item based on Sample item template.

6. Navigate to Home item (/sitecore/content/Home).

7. Right click >> Insert >> Sample item

171
8. Name it as trial item.

9. The title will be prepopulated based on the name given. Enter some value in Text field.

10. As we see there is warning informing the content editor that your content will not be published
because it is in workflow.

11. Now let’s see where we can see all the items in workflow – Work Box. The option is available in lower
left corner.

12. Select ‘Sample Workflow’ in the list.

172
13. And we can see the Trial item in the Draft state.

14. Check the box at the left of the Trial item and Click on Submit (selected).

173
15. Now if you see then the item is switched to Awaiting Approval state.

16. Now if we approve then the item will be published. Check the checkbox and click on Approve
(selected).
17. You can try rejecting and see if the item is moved to Draft.

That’s all about the workflows. We use workflows when we want the content to be reviewed and passed to
the website ex. Blogs, new articles, etc.

Schedulers
Tasks are also out-of-the-box feature of the Sitecore which allows scheduling a certain task to be run at
periodic intervals. This is also very simple to configure with minimal efforts.

The Sitecore task runner, usually called Scheduled Tasks, is a simple way of executing code with intervals. You
can configure scheduled tasks in Sitecore, at /sitecore/system/Tasks/Schedules:

174
The scheduled task consists of Commands and Schedules. Command is where we have a business logic and
Schedule is where we configure the settings of the Scheduled task.

Let’s take an example we want to create an item programmatically under ‘Color’ Folder based on Fruit
template. Currently we have Black, Blue, Red and White colors in it. Programmatically we will add 4 more.

1. Go to Visual Studio solution.

2. Create a Repository folder.

3. Add a class in it – name it – Scheduler.

175
4. We need to add a method named Process which has some predefined arguments.

5. Now we will add logic to create items programmatically.

176
6. Publish the SitecoreDemo solution.

7. Reload the Sitecore Content Editor and Navigate to Commands under Tasks
(/sitecore/system/Tasks/Commands).

8. Right Click >> Insert >> Command

177
9. Name it – Test Command.

10. In Type field, we will enter our class details in the form AssemblyName.FolderName.ClassName,
AssemblyName and in Method field; we will enter the method name.

11. Let’s create a schedule now. Go to Schedules (/sitecore/system/Tasks/Schedules).

12. Right Click >> Insert >> Schedule

178
13. Name it – Test Schedule.

14. The quirkiest configuration setting is the “Schedule” field, which is a pipe separated string determining
when the task should run:
{start timestamp}|{end timestamp}|{days to run bit pattern}|{interval}
Start timestamp and End timestamp: Determines the start and end of the scheduled task.
Format is the Sitecore ISO datetime, YearMonthDayTHoursMinutesSeconds.
Example: 20000101T000000 = January 1st 2000 at 00:00:00.
(The font Sitecore uses does not help reading the timestamp at all, I know).
NOTE: If you do the format wrong, the task will not run.
Days to run: A 7 bit pattern determining which days the task must run:
1 = Sunday
2 = Monday
4 = Tuesday
8 = Wednesday
16 = Thursday
32 = Friday
64 = Saturday
So, 127 mean to run the task every day. To run the task on Saturday and Sunday, add the 2 values,
1+64 = 65.
Interval: How long time between each run. 00:05:00 means that the task will run with 5-minute
intervals.

15. Now select our test command in Command field, leave the items field blank, in the Schedule field lets
add the value as ‘20190101T000000|20200101T000000|127|00:05:00’ and in the last run field, click
Now.

179
16. Save the changes. Let’s wait for 5-10 mins till our scheduler runs for the first time and see if the four
new colors are added to Color folder.

17. Once the scheduler is running, it will update the time in Last run.

180
18. And our colors are created.

19. Now if we don’t remove the schedule from the test schedule item then it will keep creating those 4
items under Color folder after every 5 mins.

This is all about the Sitecore scheduled tasks. It is very useful when you want to archive certain items after
some time. The example below gives an idea about archiving the media files and creating its zip file.

https://acetechpro.wordpress.com/2017/12/16/creating-archive-items-in-media-library-from-media-items-in-
a-sitecore-scheduled-task/

Forms
Sitecore forms were previously known as WFFM (Web Forms for Marketers) module which now integrated
within the Sitecore and is widely useful. You can create the Forms on the fly.

How to create a Sitecore Form?


We will understand how to create a Sitecore form using one example. Consider the below form we have to
build using Sitecore:

181
182
1. Go to Launch pad. Click on Forms.

2. Click on Create to create a new form. Select the black form.

183
3. You will get the Canvas on Left and set of tools on Right side.

4. Now refer the html of the form we have kept in Notepad++.

5. In the form tag, we need class as “form-contact contact_form”.

184
6. In Sitecore, click on Settings tab, and add the Class. Click Apply.

7. Click on Design tab and drag a Section in the Canvas (a Section means a html div).

185
186
8. Click on the dragged control, from the HTML structure, we need “row” as the class of the div. Click
Apply.

9. Now we need to add 4 divs under the one we have created. That means we will add 4 sections. After
adding 4 sections under the one, the canvas will look like the below one.

187
10. Now referring to the html, first and last div needs css class as “col-12” and the middle ones need class
as “col-sm-6”.

188
11. So let’s click on each section and add it’s class and Click Apply.

12. Again referring to the Html structure all the 4 divs’ has 1 div inside it with the class “form-group”.
Let’s add the new section under all 4 and apply the class to it.

189
190
13. Now in the first sets of div, we need text area, so we will add “Multiple-line Text” from the sets of
tools.

14. Now, click on the control, and in the right bar we will see the properties related to it. Now we don’t
need Label for this control and want “Message” as a placeholder.

191
15. From the html, we need “form-control w-100” as class for this control.

16. Click Apply.

17. Similarly, we will add the next control in the middle Section for Name i.e. Single-line text control.

192
18. Click on the control, Clear the Label, give Name as Field Name and Placeholder. And the field
Mandatory.

19. Add the css class as “form-control valid” and click Apply.

193
20. Similarly, Add the Email control, remove Label, add Field name and Placeholde text as “Email”, add the
Css class, mark the field as Mandatory and click Apply.

194
21. Similarly, Add the Single-line text control for Subject field, remove the value from Label, Add Subject in
Field Name and Placeholder Text, make it Mandatory and add the CSS class. Click Apply.

22. We are done with the main structure, we need create a structure for the Send button.

195
23. Add a Section, below the one we added first. Give the Css class (form-group mt-3) to it.

24. Click Apply.


25. Add Submit Button in the new section.

26. Click on the button.

196
27. Update the text of the button to “Send”, add the CSS class (button button-contactForm boxed-btn).

197
28. Scroll down, to set the Submit actions.

29. Click on the + sign, and select Save data.

198
30. Again click on + sign and select Redirect to the page.

31. Click OK.


32. Click Apply.

199
200
33. Click on Save.

34. Give the name of the Form (Contact Form) and click Save.

35. Go to the Content Editor.


36. Navigate to the Contact item. >> Presentation tab >> Details >> Edit >> Controls >> Add.
37. Select the Mvc Form rendering (/sitecore/layout/Renderings/System/Forms/Mvc Form) and use
“contact-form” as a placeholder key because we have set it the placeholder in the
ContactFormSection.cshtml. Also check the checkbox to open properties immediately.

201
38. Select the contact form as a data source.

202
39. Click OK >> OK >> OK.
40. Publish the Site using incremental publish.

41. Browse the Contact page on the Front end site.

Where do we get the data related to a form?


So with the above steps, we achieved the Contact Form without any piece of code. Let’s learn from where and
how can we get the data submitted by user. Try to submit 3-4 entries using the contact form.

1. Go to the Launchpad.
2. Click on the Forms.

203
3. Check the check box of the Contact form, and click on the down arrow at the top.

4. Select the Date range option if you are looking for specific date range else download the complete list
by click OK.

5. One CSV file will be downloaded.


6. To open it in a readable format.
7. Open excel, go to Data tab and click on “From Text”.

204
8. Browse & select the CSV file which we have downloaded from Sitecore.

205
9. Selected the Delimited radio button and click Next.

10. Check the checkbox for Semicolon and uncheck the tab one.

206
11. Click Next >> Finish >> OK.

207
12. And you can see the User data for the Contact Form.

208

You might also like