Posts

Showing posts from February, 2021

Unlock Full Rich Text Editor In Sitecore

Image
As Usual Sitecore Team not forget hidden gems, This blog will let you enable all hidden buttons in Sitecore RTE (Rich Text Editor) as per your requirements. Sitecore provide us with more than one profile in Core Database for RTE, I will show you each one with path in core Database: Profiles Path: "/sitecore/system/Settings/Html Editor Profiles" Profiles Types: There's four types of profiles for RTE  click on Images to view the full size Default IDE Medium Full How To Apply: Step 1: Create new config file Step 2: Add the following code to change the default RTE <sitecore> <settings>      <setting name="HtmlEditor.DefaultProfile" value="/sitecore/system/Settings/Html Editor Pr...

Sitecore Images ALT text

Image
As you know the Images in Sitecore uses Unversioned  template which uses the default language "en", but what if you need to use Alt Text in other languages, and you don't want to add the text for each language? I actually tried many things to do this 😰 my first solution was to make custom processor for uploading images and control the whole process, but this not worked for me as I was uploading images with alternative text from Item not from Media Library, unfortunately this not worked for me as the alt text was empty when uploading the images I made too much debugging to know Why!! and also did a reverse engineering on Sitecore.Kernel.dll through ILSpy  but nothing useful to me Then I tried to take a look at the templates of the Images, I found that all fields is Shared except the alt text and I remembered that all fields were filled with data while debugging except the alt Field Th...

Hidden things about Constructor in C#

Image
  What's constructor? It's a special method used to initialize an object or struct, limit access to object or control object or structs by set default values, In brief it's like the key to the door, let's say you want to run your car what do you need to do this? of sure you need the Key to run, so the Constructor in this case to run function of the Car has a Parameter called Key, without the Key you cannot run public class Car { string _key; public Car(string key){ // the constructor, accepts string key as parameter _key=key; } } Parameterless constructors: If you didn't create any constructors in your class, then C# creates the default P arameterless Constructor that initialize C# types default values, and the same on Structs, and if you have Static Fields then C# by default creates Static Constructor to initialize those Fields into default value   ...

Double VS Decimal In C#

Image
If you are using double or float in financial arithmetic operations, please stop ⛔  this !! the basic difference between double and decimal is that decimal and float is a numeric type with base 2 that means only number with base 2 are expressible in these types while in our daily basis we use numbers with base 10, 0-9 numbers Sample code: decimal dcm = 4m / 12m; // 0.3333333333333333333333333333 double dbl = 4.0 / 12.0;// 0.333333333333333 dcm + dcm + dcm + dcm + dcm + dcm; //1.9999999999999999999999999998 dbl + dbl + dbl + dbl + dbl + dbl; //2 As you can see in the upper code there's a rounding error,  the correct value should be 1.9  while in double it was 2 References: Microsoft

C# Integral Types That Lack Arithmetic Operations

Image
In C# there's some types that lack arithmetic operations These Integral types are 8 and 16 Bit so it's converted implicitly to the largest types, below is the list of these types : byte sbyte short ushort Sample of code: short a=10,b=10; short sum = a+b; // compile time error The solution: as mentioned a and b   variables   are implicitly  converted to the largest type "Int" , to solve this we have to use the explicit casting on the total result: short a=10,b=10; short sum = (short)(a+b); // compiled successfully References: Microsoft