Surendra Sharma

Surendra Sharma

Search This Blog

Friday, June 30, 2023

Embed Sitecore 10.3 form to external website page

Today, we are going to discuss how to embed a Sitecore 10.3 form on an external website. Sitecore 10.3 is available in the market and offers many new features, including headless SXA and web hooks. The new Sitecore forms use an Embeddable Form Framework, which means that you can create the forms within Sitecore and use them on any type of website, regardless of the technology used.

The benefit of this is that you can collect data from non-Sitecore-based websites and import it into the Sitecore website. This feature is similar to the old FXM feature.

Here are the steps to implement it

·       Install Sitecore 10.3

·       Rebuild the master and web index

·       Install Sitecore Headless Service 21.0.0

·       Create and publish an API key

·       Create and publish a new form in Sitecore

·       Download the Sitecore Embeddable Forms

·       Copy the CSS folder and Javascript file to your website's root folder

·       Specify the form ID in your HTML or PHP website

·       Include the script in your HTML or PHP page

·       Pass the API key to the script

·       Specify any necessary CSS elements on your HTML or PHP page

Here is my Youtube video for the same

 


Stay tuned for more such articles, tips and tricks.

Thursday, June 29, 2023

Sitecore Mindmap

Sitecore is a complex platform with many products, features and functionalities, and it can be challenging to keep track of all the details.

A mind map can serve as a single source for quick and easy access to information about a Sitecore products and its different features. It can also be used as a reference guide to quickly find specific information or to communicate the products to the clients, team members and stakeholders.

So I created Sitecore mindmap for reference


I am open to any suggestions or feedback on what else could be included in this mind map that may have been missed!!!!

Here is my YouTube video for the same



Stay tuned for more such articles, tips and tricks.

Wednesday, May 31, 2023

Webhooks in Sitecore 10.3




Today we are going to see new features of Sitecore called Web Hooks. Before understanding web hooks, let's try to understand the concept of hooks in general life. Just like we have hooks in our home to hang clothes or fishing hooks, these hooks can hold two different things and join them. Similarly, in programming, web hooks can allow interaction between different applications.

When two different web applications are present, they can be interacted through a callback function. One application can receive real-time notifications through an event. For instance, if something is happening in application one, it will trigger a notification for the other application, which will receive it in code terms. Web hooks can be used in two places: events and workflows. Whenever an item is created, deleted, copied, published or a workflow is submitted, these actions are considered events.

Web hooks can be used to track these events. Sitecore will send information about the event in terms of a JSON request payload to the other application. The Sitecore HTTP post request will be sent to the other application with the payload in JSON or XML format. The other application will receive the request and further process it. There are three types of web hooks that can be created: web hook event handler, workflow, and validation actions.

Here are the steps to implement

·       In Sitecore, web hooks can be created through the System section and Web Hooks option.

·       To create a web event handler, select a specific event (item added, copied, deleted, etc.).

·       Specify the URL for the other application and enable the event.

·       A demo was shown with a method created in the Target application to receive input from Sitecore and save it to a file.

·       When an item was added in Sitecore, the event was triggered and a file was created on the local machine with the input received from Sitecore.

Here is my YouTube video for the same

 



 

Stay tuned for more such articles, tips and tricks.

Sunday, May 28, 2023

Simplest way to sort child items in Sitecore

Today, we're going to explore another hidden feature of the Sitecore.

By default, all items created within the Sitecore are sorted alphabetically. However, if the position of the items has been changed by the content author, the list may not be sorted. In this case, sorting the items manually by clicking on the "up" or "down" option for each item would take a lot of time, especially if there are hundreds of items under a single parent item.

To solve this problem, the easiest way is to select the folder and click on the " sorting" option. This will open a "sort order" window where you can sort the items by different options such as "created date" or "reverse". To reset the order, simply click on "reset", and the items will be sorted accordingly.

This feature is hidden and simple to use, so I hope you will take advantage of it in your project.

Here is my YouTube video for the same



Stay tuned for more such articles, tips and tricks.

Thursday, May 25, 2023

ChatGPT with Sitecore

Today, we are going to take a look at something really cool - Chat GPT. In recent weeks, this technology has been a hot topic of discussion. Chat GPT is a dialog-based artificial intelligence chatbot that can answer your questions in a conversational manner. It's developed by OpenAI, a well-known research lab. The best thing about Chat GPT is that it is stateful, meaning it can remember previous questions and respond accordingly within the same context. You can find more information about Chat GPT on the OpenAI website.

As a developer, one use case for Chat GPT is to migrate CSV or Excel data to Sitecore. For example, if a client asks for assistance in migrating data, a developer can use Chat GPT to determine the best approach for accomplishing this task. The first step is to find out the different ways to migrate data and choose the best option. Once the data is migrated, the developer can assign icons, create packages in Sitecore, and publish the items.

The Chat GPT home page provides lots of information about the technology and can be used to help with a developer task such as migrating Excel file data to Sitecore. By asking Chat GPT for help, the chatbot can provide information on different methods, such as using a custom script or a C# code. Chat GPT can even provide the necessary code to complete the task, such as a C# script or a PowerShell script. The developer can then copy and paste the code into their application and test it.

Here is my YouTube video for the same

 


Stay tuned for more such articles, tips and tricks.

Monday, May 22, 2023

Insights from the "15 Ways of Content Migration to Sitecore" webinar

 Introduction:

On May 20, 2023, I presented webinar on "15 Ways of Content Migration to Sitecore", offering valuable insights and practical strategies for successfully transitioning content to the Sitecore platform.

Understanding the Complexity of Content Migration:

Content migration is a critical phase in any Sitecore implementation project, requiring meticulous planning, strategic decision-making, and a thorough understanding of both the source and target systems. The webinar emphasized the importance of recognizing the complexity involved in content migration and provided attendees with a different way to achieve it.

Exploring 15 Effective Content Migration Strategies:

The core focus of the webinar was to equip participants with a diverse set of strategies and techniques to tackle content migration effectively. I navigated through 15 different approaches, each tailored to address specific scenarios and requirements. From manual content transfer to automated migration tools, attendees gained insights into a wide range of methodologies to streamline the migration process.

Empowering Sitecore Professionals:

The "15 Ways of Content Migration to Sitecore" webinar left attendees feeling empowered and equipped with a wealth of knowledge to tackle content migration projects with confidence.

Here is the YouTube video for the same!!!




Sunday, April 30, 2023

5 ways to set Alt text for images in Sitecore

Introduction:

Alt text is a crucial part of website accessibility and SEO, as it provides a description of the content of an image to people with visual impairments. Sitecore provides various ways to set Alt text for images, from manual to automatic using AI. In this article, we will explore the different ways to set Alt text for images in Sitecore, including manual, via C# code, via PowerShell, using Config setting "Media.AutoSetAlt", and AI with sample code.

Manual:

The most basic and straightforward way to set Alt text for images in Sitecore is to do it manually. You can do this by uploading the image to the Media Library and setting the Alt text manually in the "Alt" field of the image. When you click on the image, you will see the editing options on the right-hand side of the screen. In the "Alt" field, add a description of the image, which will be read by screen readers.

AI with image tagging:

This approach uses Azure Cognitive Services' Computer Vision API to generate a description of an image and sets it as the alt text of the corresponding image item in Sitecore using C# code.

The steps involved in this approach include installing the Azure Cognitive Services Computer Vision NuGet package, creating an instance of the ComputerVisionClient class with your subscription key and endpoint, and calling the AnalyzeImageAsync method to get a description of the image.

The retrieved description is then set as the alt text field of the image item in Sitecore using the Sitecore API.

This approach can be useful when you have a large number of images in Sitecore that require alt text descriptions, as it can automate the process of generating descriptions and setting them for each image item.

However, it's important to note that the accuracy of the generated descriptions may vary depending on the image and the complexity of its content. Therefore, it's recommended to review and potentially modify the descriptions as needed to ensure they accurately reflect the content of the image.

Via C# code:

If you want to set Alt text for images programmatically, you can do so using C# code. You can use the Sitecore API to set the Alt text for an image. Here is an example code snippet:

 

using Sitecore.Data.Items;

using Sitecore.Resources.Media;

 

// Get the MediaItem for the image

var mediaItem = (MediaItem)Sitecore.Context.Database.GetItem("/sitecore/media library/Images/my-image");

 

// Save the changes

mediaItem.Editing.BeginEdit();

mediaItem.Alt = "This is my image";

mediaItem.Editing.EndEdit();

 

In the code above, we first get the MediaItem for the image we want to set the Alt text for. Then, we set the Alt text using the "Alt" property of the media item. Finally, we save the changes by calling "BeginEdit" and "EndEdit" on the media item.

Via PowerShell:

Sitecore PowerShell is a powerful tool that allows you to automate tasks in Sitecore. You can use PowerShell to set Alt text for images in bulk. Here is an example script that sets the Alt text for all images in a folder:

$imagesToBeUpdated = "/sitecore/media library/2023 Images"

$images = Get-ChildItem -Path $imagesToBeUpdated -Language * -Recurse |

Where-Object { ($_.Fields["Alt"] -ne $null) -and ($_.Fields["Alt"].Value -eq '' -or $_.Fields["Alt"].Value -eq '$name') }

 

$images |

    ForEach-Object {

        write-host "Updating Alt text for - " $_.Name

        $_.Editing.BeginEdit()

        $_["Alt"] = $_.Name

        $_.Editing.EndEdit() | Out-Null

    }

 

In the script above, we first get the folder we want to set the Alt text for. Then, we loop through all the media items in the folder using the "Get-ChildItem". For each media item, we check if the Alt text is empty, and if it is, we set the Alt text using the "BeginEdit" and "EndEdit" methods.

Using Config setting "Media.AutoSetAlt":

Sitecore also provides an automatic way to set Alt text for images using a configuration setting called "Media.AutoSetAlt". When this setting is enabled, Sitecore will automatically set the Alt text for an image using its file name. Here's how to enable this setting:

1.      Open the Sitecore.config file located in the \App_Config\Include\ folder

2.      Search for the "Media.AutoSetAlt" setting in the file.

3.  <setting name="Media.AutoSetAlt" value="true" />

 

3.     Save the Sitecore.config file.

Now, when you upload an image to the Media Library, Sitecore will automatically set the Alt text using the file name. For example, if you upload an image named "my-image.jpg", Sitecore will set the Alt text to "my-image".

Conclusion:

In conclusion, setting Alt text for images is essential for website accessibility and SEO. Sitecore provides various ways to set Alt text for images, from manual to automatic using AI. Each method has its own advantages and disadvantages, and you should choose the method that best fits your needs. Manual and C# code methods are suitable for setting Alt text for individual images, while Sitecore's with AI solution provides an advanced way to set Alt text by analyzing the image. Whereas PowerShell is suitable for bulk operations. Finally, using the "Media.AutoSetAlt" setting is suitable for setting Alt text automatically based on the file name. By using these methods, you can ensure that all images on your website have appropriate Alt text and are accessible to everyone.

Here is video for the same