Skip to main content

Posts

Showing posts from October, 2022

Adding Custom Classes in body tag of page in Sitecore SXA

Hello learners, Welcome to Learn Sitecore. In this blog we will see how to add custom classes in the body tag of page in Sitecore SXA. This is useful when we need to add classes in the body tag based of the evaluation of some conditions.  For example let's consider a scenario where the requirement is to add a class or classes to the body tag of the page when the user is logged into the website. In this scenario, we can not use the Sitecore OOTB body class field which is present on the page because it will add class to the body tag irrespective of user logged in or not.  So to achieve this requirement, we have two ways. They are  1. Override the Sitecore OOTB pipeline processor available in Sitecore SXA as shown  Decorate Page Pipeline 2. Add a new processor to the Decorate page pipeline without disturbing the existing processors.  We will see how to add a new processor into the decorate page pipeline in this post.  As we can not re-use the body class f...