Thursday 7 September 2017

How to add class to RTE field in Sitecore?

Before starting implementation,


Idea Behind adding class to RTE

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

why we are adding our class to RTE field?

So suppose you developed items and deliver to the client. Now from client side, one content author is going to edit RTE field and now if wants to apply some css to the selected content.  Then can do this but giving inline css and Now think about it that if he wants to repeat this task again and again.

So each time he had to add inline css.
And In Sitecore, "we reduce the repeating task and trying to achieve reusable logic."



Who exactly going to use and take the advantage of this ?

Definitely Content Author's life will be easy while he wants to apply specific css to the content.
They will just select the content and apply the class that's it, no need to add inline css every time.


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

Implementation

Now come to the point, Adding css Class and definition of that class once to RTE base implementation and will reuse as many as time we need.

So before starting adding Class, "Check which css is being used for RTE."

To check this go to sitecore.config and find keyword as "WebStylesheet". Actually WebStylesheet is pointing to settings in Rich Text Fields.

<setting name="WebStylesheet" value="/default.css" />

By default, "default.css" is there but sometime is changed so it's good before change.


After this go to "<instance_name>/scwffm\Website\sitecore\shell\Controls\Rich Text Editor\ToolsFile.xml"

add the classname and value.


and after that write the css definition to the css file, (WebStylesheet is pointing).

Now open the sitecore instance on the private browser because sometimes the class is not getting appear even after the changes and it's because of the cache issue. If still class is not getting appear then  recycle AppPool


Let me know if still getting issue.

Wednesday 6 September 2017

Why and when to use Rich Text Editor in Sitecore?

Was thinking about RTE in Sitecore and below are my Investigation. Let me explain

Why we are using Rich Text Editor (RTE) data-type while development ?
And when to use RTE ?

Advantage of using RTE:

RTE provides advanced editing functionalities
              tools for editing like font-style, inserting sitecore link, media link, symbols and also settings like find and replace.


Like we are using Microsoft word in sitecore for RTE field
              it's like we are inserting content in Microsoft word office, we can edit font-style, inserting symbols, insert links.


We can directly apply class definition by selecting from drop-down on selected text in RTE field
              we can add our own custom class to the drop list, So that content author can apply the class to the content at the time of creation can apply class directly without help of  designer/developer.


Have different types of RTE Profiles
              we have four different types of RTE Profiles, which we can give as data-source to the field as per requirement:

  • Rich Text Default
  • Rich Text Full
  • Rich Text IDE
  • Rich Text Medium

When to use RTE data type
             When feels that content may contains links(internal or external), images or symbols then it will be good to use RTE.
And if content contains more than one line of content which contains only text or external links then instead of using RTE should use Multiline text data type.


we can also add our own custom RTE Profile as per our requirements. and on this will discuss later