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.

No comments:

Post a Comment