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 Limitations: not supporting multilingual not preparing friendly urls

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 […]

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 […]