Try our conversational search powered by Generative AI!

How to refresh content tree on page publish


Using EPiServer CMS 11
Using EPiServer Find 13

I've created an initialisation module that moves pages 'on publish', which could include creating other pages and adding children. My issue is that if I create content 'on publish', then many times the new content is not displayed in the content tree until I reload page. Our concern is this isn't a very good experience for editors.

I've tried hooking into the dojo 'topic's to check which event is published, but I cant find any specific publish event. Next issue is I dont know how to refresh only a single panel, so I presume I have to reload the entire page? 

aspect.after(topic, 'publish', function (topicName,event) {
    topic.publishMap = topic.publishMap || {};

    if (!topic.publishMap[topicName]) {

        if (window.printevents) {
}, true);

the above javascript is for listening to every single event that is published, but nothing matches precisly and succintly 'on publish'

any suggestions?

Oct 15, 2018 12:59

Hi Noel

You could try and take some inspiration from Tahir's "Reload children" add-in:


Oct 15, 2018 23:28

There is no built-in way to update page tree, but there is a hack that can help you. It updates the whole tree, not just the children.

I also have initialization module. I change prototype of Publish method and prototype of MainNavigationComponent:

], function (
) {

    return declare([module], {

        initialize: function () {

            var originalExecute = Publish.prototype._execute;
            Publish.prototype._execute = function () {
                var result = originalExecute.apply(this, arguments);
                when(result).then(function () {
                return result;

            var originalPostCreate = MainNavigationComponent.prototype.postCreate;
            MainNavigationComponent.prototype.postCreate = function () {
                originalPostCreate.apply(this, arguments);

                this.own(topic.subscribe("custom-tree-reload", function () {
                    var showAllLanguages = this.tree.get("showAllLanguages");
                    // set the same value, just want to trigger refresh
                    this.tree.set("showAllLanguages", showAllLanguages);

I also have sample implementation publish event:

using System.Web.Mvc;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.ServiceLocation;
using AlloyTemplates.Business.Rendering;
using EPiServer;
using EPiServer.Core;
using EPiServer.DataAccess;
using EPiServer.Security;
using EPiServer.Web;

namespace AlloyTemplates.Business.Initialization
    public class CustomizedRenderingInitialization : IInitializableModule
        public void Initialize(InitializationEngine context)
            //Add custom view engine allowing partials to be placed in additional locations
            //Note that we add it first in the list to optimize view resolving when using DisplayFor/PropertyFor
            ViewEngines.Engines.Insert(0, new SiteViewEngine());

                .TemplateResolved += TemplateCoordinator.OnTemplateResolved;

            ServiceLocator.Current.GetInstance<IContentEvents>().PublishedContent += CustomizedRenderingInitialization_PublishedContent;

        private void CustomizedRenderingInitialization_PublishedContent(object sender, EPiServer.ContentEventArgs e)
            if (e.ContentLink.ID == 9) // prevent from circular call for Alloy Meet

            var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();

            var pageData = contentRepository.Get<PageData>(new ContentReference(9));
            pageData = pageData.CreateWritableClone();
            pageData.Name = pageData.Name + "!";
            contentRepository.Save(pageData, SaveAction.Publish);

        public void Uninitialize(InitializationEngine context)
                .TemplateResolved -= TemplateCoordinator.OnTemplateResolved;

        public void Preload(string[] parameters)

The tree is updated.

Oct 18, 2018 21:31
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.