Sunday, 29 November 2020

Adding Custom CSS classes in Rich text Editor under "Apply CSS Classes" Dropdown.

In My Previous Blog I Tried to show how we can create a Custom Rich Text editor Profile, which is at times required to restrict Content editor to play with content.

In This Blog Let's explore another feature in Rich Text editor, which is How can we apply custom CSS in Rich Text Editor.

Adding custom CSS in Rich Text Editor is a Three Step Process.

1. Create a Custom CSS file which will have your custom CSS that we want to apply in Rich Text Editor.

For our reference I have created CustomRichTextCSS.css file with some random Classes.

2. Place this newly created CustomRichTextCSS.css file in our Publish Folder.

3. Now We need to let Sitecore know about this newly created CSS file by adding a reference of CustomRichTextCSS.css file in Sitecore.Config.



For the demo purpose I have added CustomRichTextCSS.css file directly in Sitecore.Config, But as a Sitecore best practice we should avoid making any direct changes  in Sitecore.Config. Instead create a config patch and add reference of the file as shown below.






Now the changes can be viewed from the field in Rich Text editor named "Apply CSS Classes"

"Apply CSS Classes" Field is by default available in  Rich Text Editor Full profile

Rich Text Full:- /sitecore/system/Settings/Html Editor Profiles/Rich Text Full.

Hope That Helps... Happy Learning 😊😊😊

Sunday, 22 November 2020

Sitecore pages in Experience editor/Preview mode does not resolve to respective sc_site in Multisite configuration.

 In a Multi site configuration, there are times when we observe sc_site is not resolving to proper website, instead it always default to sc_site=website

This is an existing issue with Sitecore 6/7 and even 8 for which Sitecore provided a patch, please refer Kb article for the patch https://kb.sitecore.net/articles/382913 try installing and making all the suggested configuration changes and the issue should be resolved.

Below is the summary of configuration changes to be done in Sitecore.config to handle the issue and resolving sc_site to respective website name.

Set rendering.SiteResolving = true.

Set Rendering.SiteResolvingMatchCurrentSite = true.

Set Preview.ResolveSite = true.

Although it did not work for me, as my website is multisite with multiple domains configured for few of the websites, for few of our websites we have configured pipe separated multiple Hosts in the sitedefinition.config.

Solution that worked for me

After going through multiple blogs and deep analysis I found that as a best practice suggested by Sitecore we should always have hostName and targetHostName configured for each site's Sitedefinition for any multisite website.

hostName="abc.com|abc2.com|abc3.com"

targetHostName= "abc.com"

So along with Changes suggested by Sitecore in the patch we configured targetHostName and hostName for each of my websites and that worked for me.

Hope that helps...

References:- https://kb.sitecore.net/articles/986056

Create a Custom Profile for Rich Text Editor

Rich Text Editor is a very well known Field type in Sitecore world, we can say a very popular one but it has its benefits and even few drawback which we can discuss in another post.

Sitecore out of the box provides three different Rich text editor profiles which are there in core database below are path for same.

Rich Text Default:-/sitecore/system/Settings/Html Editor Profiles/Rich Text Default

Rich Text Medium:- /sitecore/system/Settings/Html Editor Profiles/Rich Text Medium.

Rich Text Full:- /sitecore/system/Settings/Html Editor Profiles/Rich Text Full.

Steps to Create a Custom Profile for Rich Text Editor

There are times when we want to use an Rich Text editor for a field, but also restrict what all buttons the content author will see in Rich text editor toolbar.

1. Go to Core Database location "/sitecore/system/Settings/Html Editor Profiles"

 

2. Create a copy of an existing any one profiles (Ex:- Rich Text Full/ Rich Text Full), and give it a name.

3. Now in the newly Created Profile we have Toolbars, These toolbar contain all the buttons that we see in Rich text editor.

4. Remove or add any button from toolbar and that would be effected in newly created profile.

5. In this example, I have created a new profile called "Single Line Rich Text Custom", which has just four buttons. I deleted all the other buttons.


6. Now save the newly created "Single Line Rich Text Custom" profile item, you can then use it by specifying it as a source for Rich Text Editor field in the template.


7. Save the Template, Go to Standard Values of the template and check the output or Create any new Item using the template and Check out the output.

Hope That help.

Related Blogs

Adding Custom CSS classes in Rich text Editor under "Apply CSS Classes" Dropdown.

In My Previous Blog I Tried to show how we can create a Custom Rich Text editor Profile, which is at times required to restrict Content edit...