Tuesday, July 27, 2021

Layer Configuration

ØSitecore divides configuration files into layers.

ØEach layer consists of a dedicated folder under the App_config folder.

Ø By default, there are four layers:

²Sitecore

²Modules

²Custom

²Environment

Layer file path C:\inetpub\wwwroot\ScSample.dev.local\App_Config

The load order of configuration files

By default, Sitecore loads its configuration files in this order:

ØBasic system files, such as layers.config, ConnectionStrings.config, and web.config.

ØConfiguration files in the Sitecore layer.

ØConfiguration files in the Modules layer.

ØConfiguration files in the Custom layer.

ØConfiguration files in the Environment layer.

ØWithin each layer, by default, Sitecore goes through all the subfolders in the layer recursively and loads the files in each subfolder in alphabetical order.

Control the load order of configuration files

ØIn the /App_config/layers.config file, add a <loadOrder> setting to the layer's definition:

 <layer name="Custom" includeFolder="/App_Config/Custom/">

<loadOrder>

</loadOrder>

</layer>

 

ØAdd the file folders or individual files inside the <loadOrder> section in the order you want them to load:

 <loadOrder>

<add path="Folder23" type="Folder" />

<add path="Folder9/sitespecific.config" type="File" />

<add path="Folder1" type="Folder" />

</loadOrder>

Disable a patch file

Disable a single patch file


ØNavigate to the patch file in the file system, and rename it to end in something other than .config. For example, rename Sitecore.Analytics.Config to Sitecore.Analytics.Config.Disabled.

ØAdd the patch file to a <loadOrder> section and add the mode="Off" attribute. For example: <add path="Sitecore.Analytics.Config" type="File" mode="Off" />

Disable all patch files in a layer

ØOpen the Website/App_Config/layers.config file.

ØLocate the relevant layer definition string, for example, the Environment layer.

ØAdd the mode="off" attribute to the layer definition. For example, to disable all the configuration files in the Environment layer:

<layer name="Environment" includefolder="/App_config/Environment/" mode="off">

----------

</layer>

Now, when Sitecore loads, it ignores all configuration files in the layer.


Sitecore Pipeline & Processor

 

Pipeline

ØA pipeline is a series of actions that execute in sequence to perform a task in Sitecore.

Ø Pipelines are fundamental to Sitecore's basic architecture. Most processes in Sitecore are defined as pipelines.

ØPipelines can be modified by developers to change, add, or remove functionality from Sitecore.

Why Pipeline?

ØPipelines are one of Sitecore’s essential integration concepts.

ØThey is used to extend existing functionality, and to allow custom functionality to be extended in the future.

Processor

ØPipelines are made up of one or more steps - called "processors."

ØWe can see the Pipelines this url

http://<hostName>/sitecore/admin/showconfig.aspx

Pipeline Example


HttpBeginRequest Pipeline

ØThe processors in the HttpBeginRequest pipeline generate and populate the Sitecore.Context class.

ØIn my Application, We have the httpRequestBegin Pipeline with 30 processors.

 


ØWhen the httpRequestBegin pipeline is executed, the processors defined above run in order from first to last.

Demo

Handle the 500 Exception in web pages

ØCurrently I can see the errors on my page. It’s not good to show to our live site.

Create a class file

 public class Handle500Exception: ExceptionProcessor

    {

        public override void Process(ExceptionArgs args)

        {

            try

            {

                ExceptionContent objex = new ExceptionContent();

                HttpContext httpContext = HttpContext.Current;

                httpContext.Server.ClearError();

                httpContext.Response.TrySkipIisCustomErrors = true;

                httpContext.Response.StatusCode = 500;

                httpContext.Response.Write(objex.GenerateExceptionPage());

            }

            catch (Exception ex)

            {

                Log.Info(string.Format("Process  -- error message -- {0}  stacktrace {1} ", ex.Message.ToString(), ex.StackTrace.ToString()), ex);

            }

 

        }

    }

 

    public class ExceptionContent

    {

        public string GenerateExceptionPage()

        {

            var context = System.Web.HttpContext.Current;

            string content = string.Empty;

            try

            {

                string domain = context.Request.Url.GetComponents(UriComponents.Scheme | UriComponents.Host, UriFormat.Unescaped);

                string errorPageLink = "/500";

 

                if (!string.IsNullOrEmpty(errorPageLink))

                {

                    content = Sitecore.Web.WebUtil.ExecuteWebPage(string.Concat(domain, errorPageLink));

                    Log.Error("Internal server error happened: " + context.Request.Url, this);

                }

            }

            catch (Exception ex)

            {

                Sitecore.Diagnostics.Log.Error("Error happened while generating ExceptionPage for 500 Error  :" + ex.Message, this);

                return string.Empty;

            }

            return content;

        }

 

    }

Create a config file

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">

  <sitecore>

    <pipelines>

      <mvc.exception>

        <processor type="Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage, Sitecore.Mvc">

          <patch:attribute name="type">Sitecon.Project.CustomPipeline.Pipeline.Handle500Exception, Sitecon.Project.CustomPipeline</patch:attribute>

        </processor>

      </mvc.exception>

    </pipelines>

  </sitecore>

</configuration>

Create New 500 Page in Sitecore

Before publishing check the ShowConfig File 


After Publishing the class and config files to sitecore instance

ØAbove config file has been overridden by my new config.

Try to hit the page Again




ØSorry, I forget to publish my 500 pages to web database.




 

Friday, July 23, 2021

WorkFlow

 Ø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.

Workflows

In Sitecore, you can implement any number of different workflows. As a minimum, each workflow must contain two workflow states – the initial and final workflow state. You can only publish an item in a workflow if it is in the final workflow state.

An example of a workflow:

All of the following workflow items are stored in the content tree:

Workflows – the parent item that contains all the subitems that make up the workflow.

States – the basic building blocks of the workflow. The workflow states represent the different stages in your content creation process.

Commands – move content items from one workflow state to another. When the command is executed, the item is moved to the workflow state that is defined in the command item.

Actions – the actions that are automatically performed on the items when they are in particular workflow states or when particular workflow commands are executed.

Demo

Create workflow




Create states





Set the Initial state




Create commands






Set the transition from one state to another




Auto publish action with done state



Defining workflow final state



Assigning workflow to a template




While trying to publish the item






When we delete the next state in the Content editor
























Sunday, July 18, 2021

Creative Exchange

 The Creative Exchange process is designed to facilitate several different teams working on a website. For example, the team that is working on the theme of the site can work in parallel with other teams.

How does the Front end teamwork in Parallel ?

ØWe can export the site theme as a Zip file.

ØThen Front end team works on it.

ØAgain we can import the files in our site

In SXA, any assets, such as images, fonts, and files that are normally referenced within the stylesheet, are considered to be part of the theme and they are imported with your CSS changes.

Change a site design using Creative Exchange

Already I have this structure, but I would like to center the text that is highlighted in the image, so I am going to export the theme and give this structure to my front-end team to design that.






You can download the Zip file. We can find the zip file in this path too

 C:\inetpub\wwwroot\Sc101.dev.local\App_Data\packages\CreativeExchange

Extract the zip file



This path is defined in Sitecore

Path : /sitecore/content/Demo SXA Sites/SXADemo/Settings/Creative Exchange Storages/Folder on server

If you open the index.CSS HTML then we could see the actual page which we saw in experience editor


So it gives a smooth feeling to frond-end team.


I have to add the CSS for this section. I am going to use the existing class from here. But we can create a new class also.

Add the CSS in the Styles section.



This is the optimized, first I have to beauty the file, then add my own CSS, minify the file

After that, for confirming my changes, I am going to open my index file

Wow, it is affected!!!!

So again I converted the files to zipping with the existing files. and going to import the file.















Steps to follow when using a PowerShell script to modify the goals in Sitecore

I have previously utilized PowerShell for item creation, modification, deletion, and presentation details in Sitecore.   Ø Recently, I attem...