4

Does anyone know how I can add a new link button to perform custom actions for the fields Image, General Link and Rich text editor on the content editor?

For example on the Rich text field we get this as out of the box: enter image description here

What I'm looking for in this case is to add a new link besides the "Edit HTML" link to perform custom actions. The same would go for the fields General Link and Image.

UPDATE: Although Dylan's response does cover part of the question I'm expanding the question to be more specific. It's not just creating the menu items on core but the implementation of it. So here are two points:

a) ideally not use a new custom field but instead add a new menu item to existing field types

b) how should be the declaration of the menu items in terms of specifying what are the commands that it trigger and how should those be implemented? For example in Experience Editor one might declare a command on a config patch file setting the type and using it to trigger the command. How would that go for the content editor?

2 Answers 2

2

I followed this article here in order to add a "Insert Telephone Link" to the General Link field: https://www.akshaysura.com/2015/02/22/add-telephone-link-to-the-general-link-field-type-in-sitecore/.

Basically, you'll do:

  1. In the Core database, add a menu to the field;
  2. Create a new class to handle the link message you set in the menu;
  3. Create a patch for the class that handles the link message;
  4. Create a Dialog for the menu using XML;
  5. Create a class to act as the code behind for the XML;
  6. Create a class to handle the rendering of the new menu;
  7. Finally, create a config patch for the handler.

Let me know if that works for you.

3

Sounds like you are looking for custom menu options, which you can edit in the Core database by going to this location:

/sitecore/system/Field types

I'd suggest creating a new custom field that extends upon the Rich Text, General Link or other Field Types rather than customizing the existing sitecore OOTB fields.

So for example if you wanted to add additional menu items to the Rich Text Field, you could go to this item /sitecore/system/Field types/Simple Types/Rich Text and open up the options and under Menu you should see the 3 options that you showed in the screenshot above.

Now when you add an additional menu item, you will need to specify what it triggers. Typically you would want it to trigger an action that would take place in the main code base for your custom field, which depending on the message you send, it would trigger custom logic. Often this would trigger a custom Sheer/Speak dialog where the user would fill in further input information to affect the field depending on your needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.