How your site appears in google search results

Search engines now look deep into site contents and try to understand more about your site e.g. Google uses structure data to understand more about the content on your page. By providing structured data we not only can get the benefit of special features like rich snippets but also our site will be eligible to …

Get Specific Elements Blocks from EPiServer Forms

A small extension to get the specific form elements block with all properties rather relying on  FriendlyNameInfo with the limited set of properties. EPi Form Extensions Gist Example: Custom form element block: public class HiddenExternalValueElementBlock : HiddenElementBlockBase{    [Display(Name = “Enable if its a special campaign”)]    public virtual bool MySpecialCampaign { get; set; }     [Display(Name = “Propperty 1”)]    public virtual bool Property1 { get; set; }     [Display(Name = “Property 2”)]    public virtual bool Property2 { get; set; } } Extension Methods: using EPiServer.Core;using EPiServer.Forms.Core;using EPiServer.Forms.Core.Models;using EPiServer.Forms.Helpers.Internal;using EPiServer.Forms.Implementation.Elements;using System.Collections.Generic;using System.Linq; namespace PixieDigital.EpiServer.Extensions{    public static class FormExtensions    {        public static IEnumerable<T> GetSpecificFormElements<T>(this FormIdentity formIdentity, bool filteredItemsOnly = true) where T : ElementBlockBase        {            return GetSpecificFormElements<T>(formIdentity.GetFormBlock(), filteredItemsOnly);        }         public static IEnumerable<T> GetSpecificFormElements<T>(this FormContainerBlock formContainerBlock, bool filteredItemsOnly = true) where T : ElementBlockBase        {            if (formContainerBlock != null && formContainerBlock.ElementsArea != null && formContainerBlock.ElementsArea.Items != null && formContainerBlock.ElementsArea.Items.Count() != 0)            {                var formElements = filteredItemsOnly ? formContainerBlock.ElementsArea.FilteredItems : formContainerBlock.ElementsArea.Items;                 foreach (var item in formElements)                {                    T element = item.ContentLink.GetContent((formContainerBlock as ILocale).Language.Name) as T;                    if (element != null)                    {                        yield return element;                    }                }            }        }    }} Usage: Guid formGuid = “xxx-xx-xxxx”;var formIdentity = new FormIdentity(formGuid, “en”);var hiddenElement = formIdentity.GetSpecificFormElements<HiddenExternalValueElementBlock>();//Use it for further processingvar formId = hiddenElement.FirstOrDefault().Content.ContentLink.GetElementName(); var definedElementName = hiddenElement.FirstOrDefault().Content.Name; var mySpecialCampaign = hiddenElement.FirstOrDefault().MySpecialCampaign;                        

Azure based architecture for serving EPiServer CMS As Content Hub

This architecture uses the Azure API Management to provide access to content from EPiServer for different channels. Contents are exposed via headless API and other Custom written APIs. Editors and admins will have secure access to EPIServer CMS. API Management is used to publish APIs to external, partner and channels, securely and at scale. Application Insights is used to detect …

Serialize IContent to use in Angular like front technologies

(A self note) A generic service to convert IContent into an Expando Object, ExpandoObject  can be converted into JSON to use in Angular/React components.Find the code gist https://gist.github.com/khurramkhang/e8d4b9ef093fe30610be986efa352744 Limitations: not supporting multilingual not preparing friendly urls

Few best practises while working with orders

Validate the status of line item (at required stage in sale flow) to make sure the product is active, within the valid date range, and that the catalog entry is available in the current market. Validate the status of line item (at required stage in sale flow) to make sure business does not lose money. It …

How to render SVG in edit mode

Self note: SVG is a smart media format that enables us to use same image in different sizes without compromising on quality and performance. EPiServer supports SVGs but images will not display in editor mode while using the IMG tag, as media urls are updated with version details. e.g. “globalassets/160-835st_bilok_2_screw_straight8mm_x_35mm.svg” will change as  “/episerver/CMS/Content/globalassets/en/160-835st_bilok_2_screw_straight8mm_x_35mm.svg,,1823?epieditmode=False&amp;visitorgroupsByID=undefined”. EpiServer …

POC custom pricing provider works

In most ecommerce websites, prices comes from some third system and we import the prices into EPiServer Commerce along with products and variants data, but this is not the case all the time. In some scenarios pricing are quite complex and have to decide at run time or require to retrieve from some web services. …

Custom Line Item Validator

Amazon offers AddOn products that can be bough with some other product only. Addon products must be removed from basket if added without the parent product. This type of validation can be done easily by implementing ILineItemValidotr interface. You can find a test implementation of custom Line Item Validator on Git. You will require to …

Blocks for EPiServer Commerce Catalog Nodes

Can we use Blocks with Catalog nodes? In theory Yes, what can stop you. We had a requirement when CMS editor can add a Carousel Block to Catalog Nodes. But Block Gadget was not available in CMS Catalog Edit Mode. Only available gadgets were Catalog, Media, Latest and Versions. From architecture point of view I …