Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Anders Hattestad
Oct 25, 2011
  4082
(2 votes)

Change page properties caption and help text when using PageTypeBuilder

I have some web administrators that would like to change the caption and help text for the page properties. This could be done using the xml files in lang/ folder. But since it’s a one language site and the actually editing in these xml files is a bit hassle I have wrote a admin plugin that do this for me.

The concept is that I change the EditCaption and HelpText for the property after PageTypeBuilder have set those to the default values.

This can be done by using the ModuleDependency attribute on the start up class like this.

  1. [EPiServer.Framework.ModuleDependency(typeof(PageTypeBuilder.Initializer))]
  2. public class AttachEvent : IInitializableModule
  3. {
  4.     #region IInitializableModule Members
  5.     static EPiServer.PageEventHandler DefaultHandler = new EPiServer.PageEventHandler(Instance_LoadedDefaultPageData);
  6.     public void Initialize(EPiServer.Framework.Initialization.InitializationEngine context)
  7.     {
  8.         PageTypeDefinitionsData.UpdatePageDefinition();
  9.         EPiServer.DataFactory.Instance.LoadedDefaultPageData += DefaultHandler;
  10.     }

I have therefore a DSS store

Code Snippet
  1. [EPiServerDataStore(AutomaticallyRemapStore = true, AutomaticallyCreateStore = true)]
  2. public class PageTypeDefinitionsData : IDynamicData
  3. {
  4.     public EPiServer.Data.Identity Id { get; set; }
  5.     public int PageDefinitionID { get; set; }
  6.     public string Name { get; set; }
  7.  
  8.     public string EditCaption { get; set; }
  9.     public string HelpText { get; set; }
  10.  
  11.     public string Old_EditCaption { get; set; }
  12.     public string Old_HelpText { get; set; }

where I save the old caption and help text right after PageTypeBuilder have set them. I can therefore if my administrators remove the caption use the old value instead. I then store the new caption and help text in the DSS using this admin interface

image

So when I change the EditCaption like this

image

The property caption will change, and the caption will be remembered.

image

Joel wrote that 1.9.3 of PageTypeBuilder don’t override any settings not set in code, but edit caption is always set I think. The help text is not always set thou. But I like to write in a help text, but that text sure need some finishing.

See full code here

Oct 25, 2011

Comments

smithsson68@gmail.com
smithsson68@gmail.com Oct 26, 2011 08:26 AM

What is this "DSS" store you keep using? ;-)

Anders Hattestad
Anders Hattestad Oct 26, 2011 08:43 AM

Lol :) guess my spell checker is a bit off:)

Oct 26, 2011 09:24 AM

Great post! Thanks for sharing Anders.

Please login to comment.
Latest blogs
Solving the mystery of high memory usage

Sometimes, my work is easy, the problem could be resolved with one look (when I’m lucky enough to look at where it needs to be looked, just like th...

Quan Mai | Apr 22, 2024 | Syndicated blog

Search & Navigation reporting improvements

From version 16.1.0 there are some updates on the statistics pages: Add pagination to search phrase list Allows choosing a custom date range to get...

Phong | Apr 22, 2024

Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog

Azure AI Language – Abstractive Summarisation in Optimizely CMS

In this article, I show how the abstraction summarisation feature provided by the Azure AI Language platform, can be used within Optimizely CMS to...

Anil Patel | Apr 18, 2024 | Syndicated blog

Fix your Search & Navigation (Find) indexing job, please

Once upon a time, a colleague asked me to look into a customer database with weird spikes in database log usage. (You might start to wonder why I a...

Quan Mai | Apr 17, 2024 | Syndicated blog