Try our conversational search powered by Generative AI!

Shamrez Iqbal
Dec 18, 2014
  3576
(3 votes)

Adding StartPublishDate to PageTree tooltip

In my previous blog post I demonstrated how to customize the tooltip, but it turned out we needed to add the StartPublishDate property to the Tooltip, and it turned out that the item object in the javascript file did not contain this property, so time for some more hunting.

episerver/cms/Stores/contentstructure/This time I started out in the network tab of F12 showing only XHRs. Looking at the different requests I noticed most of them looked very similar so I had to dig through the contents until I found a call containing PageData and I eventually I found one.

image

Looking at the URL the data came from something called /Stores/contentstructure/ which ContentStructureStore is handling - which inherits from RestController.

A new customization point was needed. Looking at how this REST-controller retrieved data I noticed that the data was is converted into Model objects using something called ContentStoreModelCreator.

The ContentStoreModelCreator has a constructor which takes an enumerable of IModelTransform. This looked like a promising extension point, searching for implementers of this store I found PopulatePageDataModel. As in the previous post, I created a class inheriting from this class.

What PopulatePageDataModel basically does is, it has an array of property names in an array, and tries using the weakly-typed way of retrieving this data. My class added the “PageStartPublish” to the array, and modified the TransformInstance method to use my collection instead.

   public class MyPopulatePageDataModel : PopulatePageDataModel
    {
        private static readonly string[] PropertyNames = new string[]
    {
      "PageLanguageBranch",
      "PageExternalURL",
      "PageChildOrderRule",
      "PageSaved",
      "PageChangedBy",
      "PageCreated",
      "PageChanged",
      "PageTypeID",
      "PageVisibleInMenu",
      "PageShortcutType",
      "PageShortcutLink",
      "PageLinkURL",
      "PageStartPublish"
    };
        public override void TransformInstance(EPiServer.Core.IContent source, EPiServer.Cms.Shell.UI.Rest.Models.StructureStoreContentDataModel target, IModelTransformContext context)
        {
            PropertyDictionary properties = target.Properties;
            IContent content = source;
            foreach (string key in PropertyNames)
            {
                PropertyData propertyData = content.Property[key];
                if (propertyData != null)
                    properties.Add(key, propertyData.Value);
            }
        }
    }
The next step was to Intercept it in IOC, but the PopulatePageDataModel is marked as a singleton so instead of saying InterceptWith(i=>new CustomPopulatePageDataModel()) the object is created once in the module and its called with InterceptWith(i=>MyCustomPopulatePageDataModel);
  private static void ConfigureContainer(ConfigurationExpression container)
        {
            MyPopulatePageDataModel model = new MyPopulatePageDataModel();
            
            container.IfTypeMatches(type => type.Equals(typeof(PopulatePageDataModel))).InterceptWith(i => model);

           
            
            //Implementations for custom interfaces can be registered here.
        }
There are better ways of implementing a singleton but for the sake of demo I did it in the module, it’s possible that it might be possible to define it some other way in StructureMap as well. Now, when looking at the javascript-object being sent to the getItemToolTip we can see that the PageStartPublish is available and can be added to the tooltip. image
Dec 18, 2014

Comments

Please login to comment.
Latest blogs
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

The A/A Test: What You Need to Know

Sure, we all know what an A/B test can do. But what is an A/A test? How is it different? With an A/B test, we know that we can take a webpage (our...

Lindsey Rogers | Apr 15, 2024

.Net Core Timezone ID's Windows vs Linux

Hey all, First post here and I would like to talk about Timezone ID's and How Windows and Linux systems use different IDs. We currently run a .NET...

sheider | Apr 15, 2024