Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Extending "EPiServer.Url" class



My client wants to extend "EPiServer.Url" class with the ability to set "rel" attibute.

Their reference on why: ( in Swedish ).

But basicly add support for

rel="ugc" (user generated content)

This affects "Ranking credit" for links in Google Search for example.

Any idea how to do this?

Edited, Oct 19, 2020 5:10

You could use a propertylist with the url and the option to set the rel attribute

Oct 19, 2020 12:04

For a single "EPiServer.Url" property?

[ContentType(GUID = "...")]
public class SomeRandomPage : PageData {
    [Display(Order = 100)]
    public virtual Url PageLink { get; set; }
Oct 19, 2020 12:09

hmmm, that would be overkill I guess. You could limit the amount that could be added to one though ;) But I think might be the easiest way

Oct 19, 2020 12:14

Cannot accept this solution sadly. The customer has already 5 sites in production that needs this (single solution). And I don't want to force the customer to change everywhere.

Can't you use

And inherit from Url? But I don't know if it's a propertystring or something else as a base property.

Oct 19, 2020 12:19

A custom property, even if you would inherit from Url would kinda have the same difficulties, as it would still be a different property? In your situation, with sites already in production, you could add a seperate property in which to select the rel and render them together in your view. It is/feels a bit hacky though

Oct 19, 2020 12:40

Yes. But in my maybe faulty logic, since it still inherits from Url it would easyly be converted to the new type?

I that seems to be the only simple solution sadly. Thanks!

For future refrence. How do I extend Url class?

Edited, Oct 19, 2020 12:51

How do I extend Url class? Anyone?

I want a dropdown or textbox to set the rel attribute.

Oct 22, 2020 9:00

Can you somehow do a editor descriptor and add the new field?

[EditorDescriptorRegistration(TargetType = typeof (Url))]
    public class UrlEditorDescriptor : EditorDescriptor
        public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
            base.ModifyMetadata(metadata, attributes);

Oct 22, 2020 9:18
Sameer - Apr 12, 2022 12:55
Have you found any way to add a new field in Edit Link Dialog box of EpiServer.Url property ?
Carl S - Apr 13, 2022 5:36
No. I just added a [SelectOne] factory and added a string sadly.

There are some older posts that will give you some tips on how you could do it, but dojo will be involved for sure.... So personally I would pick an easier way.  An old thread, an old post from Anders

Oct 22, 2020 9:26
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.