Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

restrict url property to allow internal and external links

Vote:
0

I want url property to allow internal pages or external links only. I do not want media files(images) and email option to be available. 

public virtual Url geturl {get; set;}

#149753
Jun 06, 2016 21:49
Vote:
0

Easiest way is to implement IValidate interface and not allow editors to save those kind of links. Customizing dojo interface takes a bit more work.

Depends on how much time you like to spend. Hours or a few days...

You can read more on custom validation here

http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-CMS/7/Validation/Validation/

#149754
Jun 06, 2016 22:36
Vote:
0

when we try to set the url property, we have options like page, media, email and external. I just want to restrict it to appear page and external only.

Could we not use AllowTypes attribute. I could see examples using AllowTypes for ContentArea, could we not use the same for url?

#149755
Jun 06, 2016 22:50
Vote:
0

Haven't tried it but don't think that would work. You can check this blog for how to play with EditorDescriptors if want to customize the dojo interface

http://www.mogul.com/en/about-mogul/blog/change-in-editor_pluginjs-for-the-extended-episerver-link-that-support-anchors

But as I said...implementing IValidate will be far easier :)

It won't hide the buttons but will make it impossible for editors to save content that contains offending links...

#149756
Jun 07, 2016 8:32
* 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.