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 24 karma points
    1 week ago
    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 5505 posts 20674 karma points MVP 3x admin c-trib
    1 week ago
    Alex Skrypnyk
    0

    Hi Pierre

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

    Alex

  • PierreCorriveau 3 posts 24 karma points
    7 days ago
    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 351 posts 1214 karma points
    7 days ago
    Marcio Goularte
    1

    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 24 karma points
    7 days ago
    PierreCorriveau
    1

    Thanks Marcio,

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

Please Sign in or register to post replies

Write your reply to:

Draft