What is Sitecore CMS?
CMS—> Content Management System
What is Content?
Whatever Text, Images, Pdf files etc viewed on the website.
What is Content Management?
Adding, deleting, updating any website content also managing its access and security without interference of the Technical Team.
CMS is a software that helps business users to add, delete, update website content along with user authorization, authentication without the need of specialize technical team members.
Basic Architecture
Authoring: Comprises Sitecore XP core services for creating managing and publishing content.
Delivery: Comprises Sitecore XP core services for displaying web content to visitors and executing in session personalization rules.
Experience Database: Comprises Sitecore XP services and storage roles that collect and store experience data.
Sitecore Frameworks
What is MVC: This is traditional Sitecore development framework which uses Asp Dot Net MVC and its concept to build sitecore website.
What is JSS: It is headless framework. It provides complete SDK which allows developers to build website using sitecore and javascript UI framework in connected and disconnected mode.
What is SXA: Sitecore Experience Accelerator (SXA) is a framework which allows teams to speed up the website development process and reuse components, templates, and Layout for various site.
Skill Set for MVC: ASP DOT NET MVC, SQL and Javascript.
Skill Set for JSS: React js, Angular.js, SQL, javascript and ASP DOT NET.
Skill Set for SXA: Sitecore JSS OR MVC, SQL, javascript.
Helix and Habitat
Helix is a set of overall design principle and convention for Sitecore development.
Habitat is a real Sitecore Project implemented on the sitecore experience platform using Helix.
High Cohesion ——-> Break the code into modules and features.
Low Coupling ——–> Reducing dependencies among those modules.
Stable Dependencies ——-> A package should only depend upon packages that are more stable than it is.
Project: This is compositional Layer where all the features are stitched together to build a website.
Feature: This has concreated features of the application. This follows common Clouser principle which is nothing but packaging classes together which change together.
Foundation: This layer defines the foundation or framework of your solution which is nothing but either business logic specific expression on the technology framework used in the implementation.
Defining Templates
Template defines the structure and behaviour of Items. Templates are the foundation for all content in Sitecore. While formally called “data templates” most developers simply refer to “templates” in the lexicon. Templates are so critical to Sitecore that they get a special node in the Content Tree.
Creation of Templates
Fields
Name: Name of the field
Type: Data type of the field
Source: Generally used as data source but depending upon data type it’s usage changes.
Versioned vs UnVarsioned vs Shared Field
Versioned Fields have different version in language and number version of an Item. By default, field is always versioned. Most of the fields that you use are versioned fields.
UnVersioned has different value for each language but share some versioned value. Most of the common example is Product name which might remain among any number version but different in language version.
Shared Field: Shared Fields has the same value across language and number version of an Item. Most of the unique Ids as product id can be shared in template.
Standard Values and Tokens
Standard values provide default values for data template fields. If the value of the field is NULL, the Item contains the standard values for that fields as defined in the data template for that Item.
- It is created manually.
- Always named as “_StandardValues”
- It allows us to update daefault value
- Set initial field values using token
Tokens
$name: The name of the Item
$id: Id of the Item
$date: The system data(yyyyMMdd)
$parentId: Id of the parent of the Item
$parentname: The name of the parent of the Item
$now: The date and Time(yyyyMMddHHmmss)
Field Source
- List Fields- DropLink, Multilist, TreeList
Location in the content tree that includes the Items included in the list displayed by the field.
2. Image and Field Type- Start folder displayed in the library dialog.
3. . Rich Text- Html editor profile controlling the feature provided by the editing interface.
Brach Template
Branch template enable users to create multiple Items using reusable, predefined structure.
How it works?
When a user chooses a branch template from the insert options, Sitecore duplicates the Item beneath the branch template definition Item, including field values, and then performs token substitution on item names and field values. You can assign branch template along with data templates and command templates.
When to use it?
* Insert multiple items.
* Assign access rights to inserted items.
* Control which accounts can insert items using the branch template.
* Provided content authors with the ability to create multiple items at once.
* Copy initial field values into a created Item.
Publishing Type
Publishing Type- Incremental, Smart, Republish
Incremental Publish: Publishing everything in the publishing queue. Do not compare items. Available only on website level. This is fastest among all.
Smart Publishing: Compare master DB and targeted publishing DB(Web) for the item, it difference found then item get published. Advisable to do at item level.
Republishing: publish everything and overwrite item in target publishing DB(Web). Ideally should not be running.
Publishing Queue: Publishing queue is one of the tables in sitecore which contains historical and current items that needs to be published. Every time item is ready for published.
Resolving a page
Browser: Sitecore pipelines are nothing but series of actions which executes in a sequence to achieve specific objective.
Rendering Types
- View Rendering
This type of rendering is a razor view. Sitecore provides a default controller and model for the view. You can customize the model by changing the MVC GET method pipeline. Use this when you want to render item content that does not require any significant business or presentation logic.
- Controller Rendering
For this type of rendering, you supply controller, model and view. You specify in the rendering defination item what action Sitecore takes to render content that relies on external data.
- Item Rendering
This type of rendering requires that content (or item) renders itself. The content has information about how it renders.
- Method Renderin
This rendering type outputs the returned value of a call to a static method.
- URL Rendering
This rendering type renders the response of a HTTP GET request onto the current page. You can use it if you need to screen scrape HTML from another system.
- XSLT Rendering
Use this to render Sitecore XSLT on sitecore MVC page. This rendering type is like the view rendering type but using XSLT as the template engine instead of razor.
Why dynamic placeholders
Placeholders within a page must be unique. You only can have a single placeholder within a page with a specific name. It generates unique suffix and add it to the placeholder key, so even though you have same placeholder key, Sitecore change key name dynamically.
Why User Switcher?
Sitecore requests are executed in the context of the current user. In non-logged in case, request is made context of anonymous user. For editing an item user should have proper permission.
User Switcher:
using (new User Switcher(user)) {}
Users Witcher allows a segment of code to run under a specific user instead of current context.
Security Disabler:
using (new Security Disabler(user)) {}
This Security Disabler elevates the user’s permission (Temporally) to administrator rights and so context users will be able to do anything on the system. This potentially vey dangerous and use errors to potentially be very costly. Anything done with the Security Disabler will show up as being done by the sitecore\Anonymous role.
Rendering Datasource
Datasource Location
The DataSource location property enables you to restrict where in the content tree items can be selected from.
Datasource Template
It specifies what type of template is compatible with a rendering.
Compatible Renderings
A compatible rendering is simply a component that can be replaced with another component providing both use the same data source type.
Compitable Rendering
Why should we use compactible renderings?
- Data is reused so saving development efforts.
- It will help you to display content in multiple ways.
- Editors can easily change design of the page withoit any code change.
Patch file in Sitecore
Patch files are used to change or add any configuration in sitecore.config file. Sitecore merges the patch files with the Sitecore. Config File to create the configuration file that is used at run time. After adding patch file in Config File, you can see this in the file like,
https:/yourcmsdomain}/sitecore/admin/showconfig.aspx
Can’t I change directly Sitecore.Config?
You must have experience how Sitecore has moved from one version to another, Every version something is changed in the configurations. How are you going handle those changes every time you have to migrate from Sitecore one version to another? How are you going to maintain these changes on different environments?
Solution to this problem is Patch File.
You need to create all the project specific patch files in one folder which will get applied on top of Sitecore platform files in any version.
Patch File helps in easy Maintenace.
How to use Patch File?
Give the patch file a name ending with the extension .config start with this basic structure in the file. In the section of the patch file, add the setting changes that you want to add to the configuration. Register the patch and set XML namespace that enables you to use attributes to modify or add settings, by adding them to the setting.
patch: before – insert the element before the specified element.
patch: after – insert the element after the specified element.
patch: attribute – define or replace the specified attribute of the element. You can achieve the same effect using the set namespace.
patch: delete – remove the specified element.
patch: instead – replace the specified element.
Layers in Sitecore
Sitecore load all the configuration in alphabetical order thus we generally add our custom patches within folder named “z” and we prefix patch file names with “z” so that last file is used to overwrite the final configuration . From Sitecore 9 onwards Sitecore introduces concept of Layes which controls the execution.
Following are basic Layes of Sitecore
- Sitecore 2. Modules 3. Custom 4. Environment
- Sitecore – It contains all default standard Sitecore configuration file which are related to Sitecore components and feature. Files related to this Layer is stored in “Sitecore” folder inside “App Config ” folder.
- Modules – This is reserved for Sitecore and it contains configuration file related to Sitecore official modules files related to this Layer is stored in “Modules” folder inside the “_AppConfig” folder.
- Custom – Contains the patch files you create in order to modify settings in the default Sitecore configuration. Files related to this Layer is stored in “Include” folder inside the “_AppConfig” folder.
- Environment – Contains the patch files you create to configure Sitecore for different environments. Files related to this Layer is stored in “Environment” folder inside “_AppConfig” folder.
Server Roles in Sitecore
Sitecore 9.0 onwards- Sitecore introduces Server Roles in configuration.
Content Management – Enables content editors to create and publish content to website.
Content Delivery – Make your web content available to your website contacts.
Processing – Extracts the information from captured, raw analytics data and transform it into a form suitable for use in reporting applications.
Reporting – Fetches reporting data from various data sources, such as the collection and reporting database, to use in Sitecore reporting Application.
Stand-alone – A single Sitecore instance performing all server roles. This is default Roles.
Role based Configuration
Sitecore allows developers to define your server instance role in the App Config file.
<add key="role:define" value="LocalInstance" />
you can have your own role and multiple roles to the single instance.
<add key="role:define" value="ContentDelivery, UATInstance" />
In the patch file you can configure which instance the configuration is applied.
<agent type="Sitecore.Tasks.HtmlCacheClearAgent" role:require="ContentDelivery">
<patch:attribute name="interval">00:10:00</patch:attribute>
</agent>
We can use “OR” , “AND”, and “NOT” operators to configure the configurations in Sitecore.
Understanding the concept
Sitecore Pipeline– Sitecore pipeline is the series of actions that executes in sequence to achieve objectives. Pipelines are used to control most of the Sitecore’s functionality and part of a basic architecture of Sitecore and can be modified by using patch files.
How to customize existing processor in Sitecore pipeline?
- You create your own processor and inherit processor class which you would want to customize or override.
- You need to use same arguments class which you want to override, you need to inherit that argument class in your own class.
- You need to create patch file which will override/extend existing pipeline patch.
Workflow in Sitecore
- Workflow – This is parent item that contains all the subitems that makes up the workflow.
- State – This is the basic building blocks of the workflow. The workflow states represent the different stages in your content creation process.
- Command – When the command is executed, the item is moved to the workflow state that is defined in the command item.
- Action – Actions that are automatically performed on the items when they are in particular workflow states.