Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • PierreCorriveau 3 posts 34 karma points
    Feb 10, 2020 @ 15:49
    PierreCorriveau
    0

    How to change Umbraco 7 title (pageName) of the page field max length?

    Hi folks,

    When typing a title more than 115 characters, I get an error page. Is there a way to change that size limit?

    I know that the best practice is to have titles lower than 60 characters but our organization requires us to have titles that are sometimes longer than 115.

    Thanks!

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Feb 12, 2020 @ 18:35
    Alex Skrypnyk
    0

    Hi Pierre

    What data type do you use for the title? Is it a textbox?

    Alex

  • PierreCorriveau 3 posts 34 karma points
    Feb 14, 2020 @ 13:24
    PierreCorriveau
    0

    Hi Alex,

    It is the default textbox for the Umbraco page name in the back office content structure. Please see the image for more details:Umbraco text box for the page name

  • Marcio Goularte 356 posts 1248 karma points
    Feb 14, 2020 @ 13:52
    Marcio Goularte
    101

    Simple way

    https://our.umbraco.com/Documentation/Reference/Events/ContentService-Events-v7

    using System.Linq;
    using Umbraco.Core;
    using Umbraco.Core.Events;
    using Umbraco.Core.Models;
    using Umbraco.Core.Services;
    
    namespace Mynamespace
    {
        public class ContentEvents : ApplicationEventHandler
        {
    
            protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {
                ContentService.Saving += ContentService_Saving;
            }
    
            private void ContentService_Saving(IContentService sender, SaveEventArgs<IContent> e)
            {
                //remove the linq for all
                foreach (var node in e.SavedEntities.Where(x=> x.ContentType.Alias.Equals("MyAlias")))
                {
                    //limit
                    if (node.Name.Length > 100)
                    {
                        e.Cancel = true;
    
                        e.Messages.Add(new EventMessage("Validation", "my error message", EventMessageType.Error));
                    }
                }
            }        
        }
    }
    
  • PierreCorriveau 3 posts 34 karma points
    Feb 14, 2020 @ 15:26
    PierreCorriveau
    1

    Thanks Marcio,

    I will try that when I go back to the office.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies