Try our conversational search powered by Generative AI!

Extending "EPiServer.Url" class

Vote:
 

Hi,

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

Their reference on why: https://www.ranktrail.se/blogg/google-infor-nya-nofollow-lankattribut/ ( in Swedish ).

But basicly add support for

rel="nofollow"
rel="sponsored"
rel="ugc" (user generated content)

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

Any idea how to do this?

#229582
Edited, Oct 19, 2020 5:10
Vote:
 

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

#229587
Oct 19, 2020 12:04
Vote:
 

For a single "EPiServer.Url" property?

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

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

#229589
Oct 19, 2020 12:14
Vote:
 

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 

https://world.episerver.com/documentation/developer-guides/CMS/Content/Properties/Custom-properties/

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

#229592
Oct 19, 2020 12:19
Vote:
 

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

#229593
Oct 19, 2020 12:40
Vote:
 

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?

#229594
Edited, Oct 19, 2020 12:51
Vote:
 

How do I extend Url class? Anyone?

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

#229734
Oct 22, 2020 9:00
Vote:
 

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);

            
        }
    }
#229737
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.
Vote:
 

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

#229738
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.