Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

limo
Oct 26, 2017
  6818
(2 votes)

Hiding properties in the built-in Link dialog

What I wanted to do was to hide the Title property in the built-in Link dialog.

Image linkdialog.png

When searching here on World I found several posts that talk about extending EpiLink with custom properties, such as:

But if I only need to hide a property, could this not be done using an EditorDescriptor instead of creating a custom dojo editor, overriding the LinkModel and all the rest?...

I was happy when I discovered that the answer is Yes :) 

I tried some variations of the below before finding the correct TargetType and way to get at the properties. This solution worked for me in a site that runs CMS 10.7:

    [EditorDescriptorRegistration(
        TargetType = typeof(LinkModel),
        EditorDescriptorBehavior = EditorDescriptorBehavior.ExtendBase)]
    public class EpiLinkEditorDescriptor : EditorDescriptor
    {
        public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
        {
            base.ModifyMetadata(metadata, attributes);
            foreach (var prop in metadata.Properties)
            {
                if (prop.PropertyName == "Title")
                {
                    prop.ShowForEdit = false;
                }
            }
        }
    }

This hides the property both in the Link dialog that opens when adding a link in the TinyMCE editor and in the Link dialog used when adding a LinkItem (the same model is used in both cases).

Image linkdialog_notitlefield.PNG

If there is a better way of doing this, please let me know!

Oct 26, 2017

Comments

Petra Liljecrantz
Petra Liljecrantz Oct 26, 2017 01:54 PM

Nice! I will definitely try this out to hide stuff from editors :) Thanks!

Please login to comment.
Latest blogs
Solving the mystery of high memory usage

Sometimes, my work is easy, the problem could be resolved with one look (when I’m lucky enough to look at where it needs to be looked, just like th...

Quan Mai | Apr 22, 2024 | Syndicated blog

Search & Navigation reporting improvements

From version 16.1.0 there are some updates on the statistics pages: Add pagination to search phrase list Allows choosing a custom date range to get...

Phong | Apr 22, 2024

Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog