Copied to clipboard

Flag this post as spam?

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


  • Jalmar 1 post 71 karma points
    Sep 17, 2019 @ 12:30
    Jalmar
    0

    Automatic title insertion in article

    I am making a lot of pages with a piece of text which is the same appart from 2 words. Those 2 words should be the page title. Is it possible to automatically let those to places be filled with the page title because there are a lot pages. Thanks in advance

  • Shaishav Karnani from digitallymedia.com 330 posts 1536 karma points
    Sep 18, 2019 @ 11:36
    Shaishav Karnani from digitallymedia.com
    0

    Hi Jalmer,

    Yes you can try using below pseudocode...

    Basically during saving event you can get the property you want to change and then replace it with whatever value.

    Hope below helps you to solve the issue.

    protected void ContentService_Saving(IContentService sender, SaveEventArgs<IContent> e)
    {
         foreach (var entity in e.SavedEntities)
         {
                if (entity.HasProperty("menuTitle") && string.IsNullOrWhiteSpace(entity.GetValue<string>("menuTitle")))
                {
                    entity.SetValue("menuTitle", entity.Name);
                }
         }
    }
    

    Regards,

    Shaishav

Please Sign in or register to post replies

Write your reply to:

Draft