AI OnAI Off
Hi!
[EditorDescriptorRegistration(TargetType = typeof(string), UIHint = EPiServer.Web.UIHint.PreviewableText)] public class ReadOnlyUrlSegmentEditorDescriptor : EditorDescriptor { public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes) { base.ModifyMetadata(metadata, attributes); if (metadata.PropertyName.Equals("iroutable_routesegment", StringComparison.InvariantCultureIgnoreCase)) { if (metadata.ContainerType == typeof (MyPageType)) { metadata.IsReadOnly = true; } } } }
Thank you, but is it possible to decide in the code what the url should be for each individual page of the same pagetype?
On your page type definition class you can try to override the SetDefaultValues method like this and set the URLSegment property on the page explicitly. Something like this (untested):
public override void SetDefaultValues(EPiServer.DataAbstraction.ContentType contentType) { base.SetDefaultValues(contentType); this.URLSegment = "my-hard-coded-url"; }
Be careful though, you don't want multiple child nodes with the same URLSegment.
In Episerver 7.19 I need to make the field for the url in the header of a page in episerver read only for some pages so that the developers can hard code the url:s instead