问题
I am working on a functionality where the user selects a Tag from a namespace and clicks a button.
Currently, we have a text box where user needs to enter the tag ID. But its not convenient for them to know the tagID.
Is there any way to create a Tags Widget
(or a Path Browser
) on a component HTML, similar to how it works in the dialog ?
I know Coral UI dependencies may be an issue, but just curious if we can achieve that. I've never done something like this.
回答1:
I hadwritten a similar answer here
AEM Tools: Tag Picker using Coral
I had overlaid the
cq/gui/components/common/tagspicker
in the apps folder, and then edited the piece of code in the render.jsp to pick the tags from the desired path.
AttrBuilder attrs = htmlTag.getAttrs(); . . . . .
attrs.add("data-basepath", cfg.get("tagsPath", tagSpace));
where tagSpace refers to the custom tag location inside the /etc/tags/customTagSpace
You can pass it inside an OSGI configuration or anything configurable, where inside the render.jsp you can pick up using scriptlets or other methods and then display it.
来源:https://stackoverflow.com/questions/55345318/aem-tag-picker-widget-on-a-page