When same component is used more than one time under same parsys, it is created using unique id like mycomponent_1526332 and so on.
Now when content author tries to reference any of those 4-5 instances created in another page using path browser, they can not differentiate between them as it shows like mycompnent_1234433, mycompnent_3243555 etc.
Question is :
1. Is it possible to control how this ID is created when node is created and we can give more meaningful name like mycomponent_01, mycomponent_02 ?
2. Is it possible to display some meaningful name in the path browser other than node name (which is only possible to know using crx/de access) ?
I am using AEM 6.3 SP2 CF1
You can do this using JCR APIs, as soon as you drop your component, a node is created in repository, you can listen CREATE event and rename the node name.
You can either use sling or JCR events
Thanks Arun for your reply. I had thought of Listener. But just don't want to add listener which will trigger it for all the requests of Node Creation throughout my multi tenant instance (I know I can request based on Path / resource type etc - but that will still come to the listener at least ones) .
I was looking for rather elegant way where it triggers only for the component I want it by adding some properties / adding :name parameter for Post Servlet / adding some mixins if possible.
I heard about Post Servlet :name parameter but not sure how to use it when the component is dragged for the first time in parsys. This will be safer option as it will trigger use the :name param where passed and do the usual node naming else where.
Hope I am making the point clear.
Yes, it is there for that but AEM uses nameHint parameter to create name while we drag and drop components.
We can easily overwrite this nameHint parameter using sling Filter but I'll check other option to overwrite nameHint this option and get back to you.
If request is posted with an URL ending in slash
/ or slash-star
/*, the SlingPostServlet derives a name for the node to be created upon the request applying the following algorithm:
:nameparameter is supplied, the (first) value of this parameter is used unmodified as the name for the new node. If the name is illegally formed with respect to JCR name requirements, an exception will be thrown when trying to create the node. The assumption with the
:nameparameter is, that the caller knows what he (or she) is supplying and should get the exact result if possible.
:nameHintparameter is supplied, the (first) value of this parameter is used to generate the node name. A name filtering is applied to this hint to ensure a valid JCR node name.
title, jcr:title, name, description, jcr:description, abstract. The first request parameter with a non-empty value is used and filtered to get the valid JCR name.
You are about to start tingling with how AEM OOTB granite UI is about to tell AEM to store data. That's probably, not the best idea in the history of AEM.
What could be better is to improve pathfinder/extend pathfinder, and bring in some rendering options(UI options) for your content authors. This functionality was partially there for classic UI, but got lost, not implemented in Touch UI.
Instead of modifying how back end stores data, make a nice presentation for your pathfinder to let content author know what they are about to choose.
Whats the purpose of "when content author tries to reference any of those 4-5 instances created in another page using path browser,"
This does not sound like best practice at all. There should be no need to an author to reference an image component -- for example - located in another page.
Thanks Peter. So we are talking about overriding path browser component rather than looking at how the nodes are created. when you say nice presentation, what is your idea ? Are you saying to try to display component title / some other field instead of node name ?
The idea is to create a page under something like /content/mysite/global/ and author all the required instances of that component under that. Then in the product specific pages, simply use reference to this.
We thought to go with content fragment but faced below challenges.
1. This is not a single field reference. It is a mini component with textfield, RTE and pathbrowser in turn. So we though to use CFM but faced limitations.
2. Also, we are on SP2 CF1 right now where CFM is disabled for some reason because of the CFP we have added.
Hence, we thought to create a custom component and reference it.