Saturday, 9 September 2017

Sitecore Custom RTE Profiles

After the understanding of RTE field now it's time to use, Change and then customize with It. Overall playing with RTE in sitecore.


So first thing is there are four types of RTE profiles which are already provided by Sitecore to navigate these RTE Profile will jump to core database at "/sitecore/system/Settings/Html Editor Profiles" and these are:

Rich Text Default
Rich Text Medium
Rich Text Full
Rich Text IDE
Rich Text Mail (newly added)





and by default when we are using RTE field in the template then Rich Text Default is already set as data source on the RTE field.





 And the best thing is we can change the data source with other existing RTE profiles.


Now it's time to create one custom RTE but before creating custom RTE, let's discuss why we need to create custom?

Suppose You want to add more tool to the RTE editor options, or just want to remove some options and you are definitely sure that in future you are not going to use. then we use custom RTE.


And now one question is raised that why we are not going to change into existing RTE profiles then my opinion is, "If we will change to the existing RTE profiles then it may impact to the existing RTE field for other items, and we exactly didn't know at what places exactly existing RTE is getting used".


So instead of taking risk we will just copy the whole RTE and will create newer one and here we will customize.


So let's start

1. will go to /sitecore/system/Settings/Html Editor Profiles

2. now will copy Rich Text Full  Profile (here will prefer to copying the existing RTE with Full functionality Profile, so that will remove which i don't want and will add according to my requirement)

3. now will move back to master database and will give the data source of RTE with new one RTE Profile which we want to use.


Please let me know if you are facing issue while using.

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.