Channel Manager: encode/replace string in Last Element while creating a new page

Hello!
I would like to know if we have an option to encode/replace the string provided for the Last Element field while creating a new page?

Seems currently it replaces / : and I would like to replace other characters as well, say ö to o, convert the string to lowerCase, etc.

Anything similar to the configuration used for the document node name encoding?

Thank you in advance!

Hi,

You could probably use PageEvent Listener to update it.

Here is a sample listener which subscribes to PageCreateEvent and updates both sitemap item (hst:sitemapitem) node and it’s corresponding page component (hst:component) node:

public class NormalisePagePropertiesListener {

    private String getNormalisedAccentString(String str) {
        String nfdNormalizedString = Normalizer.normalize(str, Normalizer.Form.NFD);
        Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
        return pattern.matcher(nfdNormalizedString).replaceAll("");
    }

    @SuppressWarnings("UnusedDeclaration")
    public void init() {
        ChannelEventListenerRegistry.get().register(this);
    }

    @SuppressWarnings("UnusedDeclaration")
    public void destroy() {
        ChannelEventListenerRegistry.get().unregister(this);
    }

    @Subscribe
    public void onPageEvent(PageCreateEvent event) throws RepositoryException {
        // Normalises accent characters on page component node (under hst:workspace/hst:pages) name
        Node pageNode = event.getPageActionContext().getNewPageNode();
        pageNode.getSession().move(
                pageNode.getPath(),
                pageNode.getParent().getPath() + "/" + getNormalisedAccentString(pageNode.getName()));

        // Normalises accent characters on sitemap item node (under hst:workspace/hst:sitemap) name
        // & its `hst:componentconfigurationid`
        Node siteMapItemNode = event.getPageActionContext().getNewSiteMapItemNode();
        Property componentConfigurationProperty = siteMapItemNode.getProperty("hst:componentconfigurationid");
        componentConfigurationProperty.setValue(getNormalisedAccentString(componentConfigurationProperty.getString()));
        siteMapItemNode.getSession().move(
                siteMapItemNode.getPath(),
                siteMapItemNode.getParent().getPath() + "/" + getNormalisedAccentString(siteMapItemNode.getName()));

    }

}

Hope this helps!

Cheers,
Selva

Thank you for the update. Yes! It works but seems the Page create event is not available in 13.3.0 version which is my current version. I think the event is available with 14 and higher.