Sitecore - "Clean" package installation for RTE button - sitecore

I am creating a Sitecore module which includes a new button within the Rich Text Editor.
In order to register the command for the button I had to append some code to the RichText Commands.js file.
I had hoped that I could create the installation package in such a way that it would be simple, without any additional manual intervention required.
So I have 2 questions:
Is there any way I can the add the javascript command registration code without amending an existing file?
Is there somewhere in the Sitecore tree I can put the button so it appears for all RTE profiles? - a sort of "global profile".

You can add your own client scripts by adding an entry into the config. Patch the following:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<clientscripts>
<htmleditor>
<script src="/sitecore modules/shell/Controls/Rich Text Editor/Custom RichText Commands.js" language="JavaScript"/>
</htmleditor>
</clientscripts>
</sitecore>
</configuration>
Here is a detailed blog post about it.
There is no setting that I know of so that all profiles display the button. You have to add it to the profiles you wish the button to show on. Either:
add it to the default profile
make a copy of an existing profile, rename it to Rich Text Default and add/remove whatever you want
Change <setting name="HtmlEditor.DefaultProfile" value="/sitecore/system/Settings/Html Editor Profiles/Rich Text Default"/> in web.config to your custom profile
If you set the DataSource of a rich text field to a different one then obviously the default settings will not take effect.

Related

Sitecore RTE not showing HTML editor tab

Using Sitecore 10.0.1
I updated the HtmlEditor.DefaultProfile in sitecore config as below so as to use bullet points and numbered lists.
<setting name="HtmlEditor.DefaultProfile" value="/sitecore/system/Settings/Html Editor Profiles/Rich Text IDE" />
But after this change not able to see the design tab/ html tab as below
Please suggest
It happens because the profile /sitecore/system/Settings/Html Editor Profiles/Rich Text IDE does not contain the item HTML View in the Buttons folder. You can check it by switching to the core database and exploring different profiles under the tree /sitecore/system/Settings/Html Editor Profiles/.
If you want to include Design/HTML tabs in the Rich Text IDE profile, you can copy the HTML View item from another profile, for instance Rich Text Default or Rich Text Full:
Alternatively, if you plan to make other customisations to the Rich Text Editor profile, consider creating a custom profile and modifying it as per your requirements.

Add a new field to Sitecore JSS

I created a simple Sitecore JSS Application and imported the same.
In connected mode, I want to add a few new fields. I added them to the template (Image 1) and they show up in the item (Image 2). When I query the item, I get the new fields in the json object as well (Image 4).
However, I cannot see the new fields in the experience editor (Image 3) and I am assuming I need to add those in the View. I am unable to locate where I need to add these fields or what I need to do, to have these show up.
Image 1: The modified template
Image 2: Both description and photo show up in the item
Image 3: Description and photo do not show up in the experience editor
Image 4: Json however returns these 2 properties
The Experience Editor use the Node.js app inside the /dist folder of your Sitecore webroot. (See also the config, you can have multiple apps)
Change your frontend, I Guess you use React, Vue, or Angular and upload/deploy to the dist folder.
You need to choose your dev workflow see:
https://doc.sitecore.com/xp/en/developers/hd/190/sitecore-headless-development/development-workflows.html
When you add your fields in Sitecore, you are using the Sitecore-First Workflow.
Hidden gem:
JSS add a extra Field "Always Display Field Editor Button in Experience Editor" to Renderings. In the Experience editor the Chrome Toolbar from a rendering has as first icon a Pencil, That opens a Field editor for all custom fields.

How do I add a custom .aspx page to sitecore?

I've recently created an aspx and aspx.cs page that needs to run alongside a sitecore website. Does anyone know how i can add these pages into the site? Our set up is very odd and would like to know recommendations before trying anything and risking breaking our setup.
You don't necessarily have to add your page to the IgnoreUrlPrefixes.
Before the ItemResolver is executed, the FileResolver is executed which checks if your request points directly to a file on disk.
You do need to configure the allowed URL extensions in the FilterUrlExtensions processor of the preprocessRequest pipeline, as such:
<preprocessRequest
<processor type="Sitecore.Pipelines.HttpRequest.FilterUrlExtensions, Sitecore.Kernel">
<param desc="Allowed extensions (comma separated)">aspx, ashx, asmx</param>
<param desc="Blocked extensions (comma separated)">*</param>
</processor>
</preprocessRequest>
So that configuration will allow *.aspx, *.ashx and *.asmx to be requested directly (it's the default configuration in Sitecore 7.0).
If you're using Sitecore 6.6 or lower, the FilterUrlExtensions processor can be found in the httpRequestBegin pipeline.
If you just drop the ASPX page in at the path you'd like it to reside, by default, Sitecore should let it be served as is by going to the corresponding URL.
Just add the pages to the projects as normal (as DustinDavis suggested) but you also need to modify IgnoreUrlPrefixes in web.config (or add a config patch file) and include the pages or folders as pipe delimited values that you want the Sitecore handlers to ignore.
You can configure the value attribute of the
/configuration/sitecore/settings/setting element in web.config with
name IgnoreUrlPrefixes to prevent Sitecore from processing specific
requests, causing ASP.NET to process the request without Sitecore.
From Sitecore Presentation Component Reference
There is more information about the how and why in this blog post by Alex Ahyba
If you have sitecore open in Visual Studio, just add them in to the project. You can access the new page directly.

Add buttons/dropdownlist to sitecore webedit editor?

Is it possible to add more buttons or a dropdownlist to the webedit editor when you are viewing the page in the page editor in sitecore?
If you look at the image below I would like to add a "H2" button in the toolbar.
You need to add it to /sitecore/system/Settings/Html Editor Profiles/Rich Text Default/WebEdit Buttons/.
And, to create a h2-button, enter the following into the Click field of the new item:
chrome:field:execute({command:"FormatBlock", userInterface:true, value:'h2'})
('h2' being the block format you want)
Yes, that is possible.
You need to modify the Html Editor Profile for this which is located in the Core database under /sitecore/system/Settings/Html Editor Profiles
If you look at the Full profile, you can find a command for H2 (and other headings) there somewhere. This can be easily copied to the profile that you are currently using (i guess it's the Minimal profile).
If you have access to the web.config, you may want to create a copy of the Minimal profile before editing it and configure it as HtmlEditor.DefaultProfile

how to load css classes from my own project specfic css in Sitecore's RAD editor?

how to load css classes from my own project specfic css in Sitecore's RAD editor? I want to give option to client to add predefined css class to any needed element.
Put the css in default.css in your websites' root folder and restart IIS. Sitecore RAD editor should pick up the classes, although we found it could take a couple of restarts.
Depending on the version of Sitecore you're using there's different ways since in 6.4 there is a new wysiwyg from Telerik's updated library.
pre 6.4 Multisite Rich Text Editor Custom CSS
6.4+ Multisite Rich Text Editor Custom Css
As stated by Adam you can add this to the default.css file. However if you want to move the CSS file else where then you need to updated the following setting in the web.config (this is the Sitecore 6 setting name, it maybe different in early versions):
<setting name="WebStylesheet" value="default.css" />