Sunday, March 23, 2025

What is Partial Design, Page Design and Page Branches in SXA and how we use in our Project?

 What is  Partial Design, Page Design and Page Branches in SXA and how we use in our Project?


Building and maintaining a consistent, scalable website can be challenging, especially as your site grows. Sitecore Experience Accelerator (SXA) offers powerful tools to simplify this process by allowing you to create and reuse modular components across your site. In this blog, we’ll delve into three key elements of SXA: Partial Designs, Page Designs, and Page Branches. These building blocks will help you streamline your website development, keep everything consistent, and make content management a breeze. Whether you're setting up a simple blog or a complex corporate site, these features will enhance your workflow and improve your site’s overall performance.



Partial Design

Partial Designs are reusable layout components that can be included in multiple page designs within SXA. They allow you to define a section of a page layout once and reuse it across different pages or page types. This modular approach ensures consistency across your site and makes it easier to manage changes and updates.


How to Create and Use Partial Designs in Sitecore

  1. Create a Partial Design:

    • Navigate to SXA > Partial Designs in the Sitecore Content Editor.

    • Create a new Partial Design (e.g., "Header," "Footer," etc.).

    • Add the required renderings through the Presentation Details of the Partial Design.

  2. Menu for Inserting Partial Designs: Once a partial design is created, it can be inserted in various page templates. This is easily done through the Context Menu or Insert from Templates within Sitecore.

  3. Device Editor Settings: Sitecore provides a Device Editor for headless configurations. In the case of a Header Menu, you can add it as a rendering, along with its data source, through the Presentation Details as shown in the screenshot below:

    Example: Headless header menu configuration for a responsive site.











Key Features of Partial Designs
  • Reusability: Define common layout elements once (e.g., headers, footers, sidebars) and use them across multiple pages and page designs.

  • Consistency: Ensure a uniform look and feel across your website by reusing the same partial designs, reducing the chances of inconsistencies.

  • Efficiency: Save time and effort by creating and updating common components in one place rather than individually on each page.

  • Scalability: Easily manage and scale your website as new pages can quickly adopt existing partial designs, maintaining the site’s design standards.

Partial Designs allow you to set up a section of a page layout once and reuse it all over the place. This way, your site stays consistent and it’s way easier to handle changes and updates. Think of it as creating a template that can be applied anywhere you need it, saving you time and ensuring everything looks just right.


Page Design

A Page Design in SXA is a selection of partial designs that help structure your pages. For instance, you can ensure that headers and footers are always in the same spot, giving your site a uniform appearance. Page designs are highly useful when you want to create a layout for specific types of pages, such as a blog page, a landing page, or a news article page.

Creating Page Designs in Sitecore

  1. Navigate to Page Designs:

    • Go to SXA > Page Designs in the Sitecore Content Editor.

    • Create a new Page Design for the specific page type you want to set up (e.g., “Blog Page Design,” “Landing Page Design”).

  2. Assign Partial Designs to Page Layout:

    • Assign your predefined Partial Designs (like Header, Footer, Sidebar) to your Page Design.

    • You can organize Partial Designs in a sequence as per the layout needs. For example, a news page might have a header, content section, sidebar, and footer in that order.

  3. Use Rules to Assign Page Designs:

    • Set conditions for when a particular design should be applied using rules. For example, you could specify that certain page designs are applied only to blog articles, while others are applied to product pages.

  4. Assign Page Designs to Page Templates:

    • You can assign Page Designs to page templates in the Presentation section under the Designing tab.

    • Map each page template to a Page Design for consistent page layouts.

Example: Page Design structure for a blog page using a header, content area, and footer.






















Page Design Benefits

  •   Structure: Set the layout of a page using reusable partial designs.
  • Consistency: Ensure uniformity across different pages like blog posts or product pages.

  • Efficiency: Easily apply consistent page layouts to all pages that share the same design template.



Page Branches

A Page Branch is a predefined structure of pages that can be reused to create new sections of your website. It includes a hierarchy of items, templates, layouts, and initial content. Page branches save time and ensure consistency by replicating the structure each time a new page is created.

Creating and Using Page Branches

  1. Set up a Page Branch:In Sitecore, navigate to SXA > Page Branches.

    • Create a new P

    • age Branch (e.g., “Service Pages”).

    • The structure will replicate across new pages created from this branch, ensuring each page includes the same initial components and layout.

  2. Auto-Generation of Components:

    • Sitecore automatically generates components like Page Title and Data Folders for each new page created from a page branch.

    • By creating these elements automatically, it ensures consistency in the layout and content across the new pages.

  3. Datasource Field Configuration:

    • In a Page Branch, configure the datasource fields to point to local data rather than global to keep the content unique for each page.






Page Branch Features

  • Consistency: Maintain a uniform structure across newly created pages or sections.

  •      Efficiency: Automatically replicate layout, data, and components for new pages.

  • Customization: Tailor content for specific sections, such as blog pages or service pages.

Page branches are particularly useful when you need to create new sections or groups of pages with a consistent layout but distinct content. For example, a service page template might have a common layout, but the Page Title and other content vary for each service.




When to Use Page Branches vs. Page Designs


  • Page Designs: Ideal for static elements that appear across multiple pages (e.g., headers, footers, and navigation). It’s useful when you want uniformity and don’t need to change the layout for every page.

  • Page Branches: Best used when creating new sections or groups of pages with different content. Each page branch maintains the layout but allows for flexibility in the content, making it perfect for sections like blogs, services, or product pages.




Conclusion: Maximize Efficiency and Consistency with SXA

In this blog, we explored how Sitecore Experience Accelerator (SXA) simplifies website development and management through three essential features: Partial Designs, Page Designs, and Page Branches.

  • Partial Designs are reusable layout components that ensure consistency and efficiency across your site by allowing you to define and reuse common elements like headers and footers.

  • Page Designs structure your pages by selecting and arranging partial designs, making it easy to maintain a uniform appearance and apply preset layouts for different types of pages.

  • Page Branches provide a predefined structure for creating new sections of your website, including hierarchical items, templates, and initial content, ensuring consistency and saving time.

Together, these SXA features help you manage your site more effectively, allowing for easy updates, scalability, and a polished, cohesive look across all pages.

For more insights on how to optimize your Sitecore website using SXA









Sunday, March 16, 2025

Computed Index in Apache Solr: What, Why, and How to Use It?

Computed Index in Apache Solr: What, Why, and How to Use It?


Introduction

Apache Solr is a powerful search platform widely used for enterprise search applications, e-commerce sites, and big data analytics. While Solr is known for its full-text search capabilities, it also allows computed indexing, where certain fields are precomputed before indexing. This technique enhances query performance, supports dynamic field calculations, and simplifies complex queries.


In this blog, we will explore:

What is a Computed Index in Solr?
Why is it useful?
How to implement it?
A real-world e-commerce example.

------------------------------------------------------------------------------------------------------------------

What is a Computed Index in Solr?

A computed index refers to a field whose value is dynamically calculated based on other fields before being indexed. Instead of computing these values at query time, Solr precomputes and stores them in the index, ensuring faster search results.

For example, if we have a product catalog with price and discount percentage, we can precompute the final price instead of calculating it during every search query.


Example:

............................................................................................................................................................

Raw Data:

{

    "id": "P001",

    "name": "Laptop",

    "price": 1000,

    "discount_percentage": 10

}


Computed Field (final_price)

final_price = price - (price * discount_percentage / 100)


final_price = 1000 - (1000 * 10 / 100) = 900

This final_price is stored directly in Solr, eliminating the need to
compute it during searches.

..........................................................................
final_price =


Why Use Computed Indexing in Solr?

Using computed fields in Solr offers several benefits:

🚀 1. Improves Query Performance

Precomputing values ensures that queries do not need to perform

calculations, making searches significantly faster.

🔄 2. Reduces Query Complexity

Instead of applying filters on multiple fields(e.g., price and discount_percentage)

we can filter directly on final_price.

3. Optimizes Sorting and Faceting

Sorting and faceting on precomputed fields is much faster than computing

values dynamically at query time.

📊 4. Custom Ranking & Scoring

You can define custom ranking based on precomputed metrics such as

weighted scores, engagement rates, or computed product relevance.


How to Implement Computed Indexing in Solr?

Method 1: Using Solr Update Request Processor (URP)

Solr provides Update Request Processors (URP) that allow modifying or

computing fields before indexing.

Step 1: Define Computed Field in schema.xml

Modify the Solr schema to include the computed field:


<field name="price" type="float" indexed="true" stored="true"/> <field name="discount_percentage" type="float" indexed="true" stored="true"/> <field name="final_price" type="float" indexed="true" stored="true"/>

Step 2: Use Solr Update Processor to Compute the Value

Modify solrconfig.xml to include an Update Request Processor:

<updateRequestProcessorChain name="compute-final-price">
<processor class="solr.StatelessScriptUpdateProcessorFactory"> <str name="script"> if (doc["price"] && doc["discount_percentage"]) { doc["final_price"] = doc["price"].value -
(doc["price"].value * doc["discount_percentage"].value / 100); } </str> </processor> <processor class="solr.RunUpdateProcessorFactory"/> </updateRequestProcessorChain>

👉 This script calculates final_price before indexing the document.


Step 3: Apply Update Processor in solrconfig.xml

Ensure Solr applies this processor to all incoming documents:


<requestHandler name="/update" class="solr.UpdateRequestHandler"> <lst name="defaults"> <str name="update.chain">compute-final-price</str> </lst> </requestHandler>

Method 2: Using Copy Fields

If the computation is simple (like duplicating values), you can use the

copyField method in schema.xml.


<field name="original_price" type="float" indexed="true" stored="true"/> <field name="discounted_price" type="float" indexed="true" stored="true"/> <copyField source="original_price" dest="discounted_price"/>

However, this method is limited since it does not support mathematical

transformations.


Live Scenario: E-Commerce Discount Calculation

Use Case:

An e-commerce website needs to display the final price of products after

applying discounts. Instead of computing it dynamically on every search,

Solr precomputes and stores the final_price.

Solution Using Computed Indexing:

  1. The raw data includes price and discount_percentage.
  2. Solr precomputes final_price = price - (price * discount_percentage / 100).
  3. Users can filter, sort, and search directly on final_price instead of
  4. computing it at runtime.

Example Query:

To find all products under $500, we can simply query:


q=final_price:[* TO 500]

This is faster than querying:


q=price:[* TO 500] AND discount_percentage:[* TO 50]

By precomputing final_price, Solr reduces query complexity and improves response time.


Conclusion

Computed indexing in Solr helps optimize performance by precomputing

field values before storing them. Using Update Processors or

Copy Fields, we can create derived fields that speed up searches,

improve filtering, and enhance ranking.

Key Takeaways:

Use Computed Indexing for Preprocessing – Compute values

before indexing, not at query time.
Boost Query Performance – Avoid expensive calculations

during searches.
Optimize Sorting & Filtering – Work with precomputed values

for better efficiency.


Next Steps:

👉 Try implementing a computed index in your Solr project! 🚀
👉 Need help? Drop your questions in the comments! 💬

Would you like a step-by-step Solr configuration guide? Let me know! 😊



Sunday, March 9, 2025

 

Creating a Custom Resolver for Descendants with Pagination in Sitecore JSS

When working with Sitecore’s Layout Service, sometimes we need to retrieve items with their children in a paginated format. In this blog, we will walk through the creation of a custom resolver in Sitecore that retrieves a given item and its child items with pagination support.

Why Do We Need a Custom Resolver?

By default, Sitecore provides content resolvers, but they may not always fit our needs, especially when working with large datasets where performance optimization is essential. A custom resolver helps control the data we return, structure the JSON output, and apply pagination.

Monday, March 3, 2025

 What is getStaticProps? And Benefits of using in XM Cloud. 

In today’s digital world, delivering a fast, seamless user experience is a key factor in keeping your visitors engaged. With search engines like Google emphasizing site speed and performance as ranking factors, it's essential to ensure that your web pages load quickly. This is where static site generation (SSG) comes into play, and when used alongside tools like XMCloud, it can dramatically enhance your site’s performance. One of the most powerful methods for implementing static site generation in a Next.js application is through getStaticProps.

In this blog post, we'll dive into how to use getStaticProps in XMCloud, its benefits, and how it can help improve your website’s load times, SEO, and overall user experience.


What is getStaticProps?

getStaticProps is a built-in feature in Next.js, the popular React framework, that allows you to fetch data at build time and pre-render the page as static HTML. When you use getStaticProps, the page is generated once during the build process and served as static content, making it fast and ready to be delivered from a CDN (Content Delivery Network) without requiring dynamic rendering on each request.

This method of pre-rendering can be a game-changer in terms of speed and user experience. But how does this work with XMCloud?