Expand my Community achievements bar.

SOLVED

TagManager doesn't find components tagged

Avatar

Level 3

Hi all,

I would like to tag components trough the cq:tags property in order to search for them quickly. However, the TagManager -> tagManager.find(tag.getTagID(); can't find them.

I believe it is related with the cq:Taggable mixin. Could it be applied to a cq:Component node type?

 

Regards,

Salvador,

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

That precisely is the reason. for a node to come up as reference in tagManager.find method, it needs to have cq:Taggable mixin. cq:pageContent type node by default has this mixin and hence Page node turns up automatically in .find API call.

You can enhance the nodeType definition on your server by modifying the file nodetypes.cnd

You can push this file as your code package from following location:

/src/main/content/META-INF/vault/nodetypes.cnd

Please refer to below link on how you can modify nodetypes.cnd file and add extensions to existing nodetypes.

https://jackrabbit.apache.org/jcr/node-type-notation.html

http://www.tothenew.com/blog/custom-node-type-in-aem/

 

Basically you need to extend cq:Component node type and make it cq:Taggable mixin default applied on it.

Try extending it on your local first and then on any environment, because if you don't get it right, then it can cause issues in your repository.

Please Note - Doing so will have performance implications on your server, so do this only if it is critically needed, or else you can always resort to using X-PATH/SQL2 in finding the tagged component nodes.

- Runal

View solution in original post

2 Replies

Avatar

Level 10

Take a look at this tag example. 

https://helpx.adobe.com/experience-manager/using/tagmanager-api-htl.html

Tags are typically applied to pages - i have not personally tried on other content pieces. 

Avatar

Correct answer by
Community Advisor

That precisely is the reason. for a node to come up as reference in tagManager.find method, it needs to have cq:Taggable mixin. cq:pageContent type node by default has this mixin and hence Page node turns up automatically in .find API call.

You can enhance the nodeType definition on your server by modifying the file nodetypes.cnd

You can push this file as your code package from following location:

/src/main/content/META-INF/vault/nodetypes.cnd

Please refer to below link on how you can modify nodetypes.cnd file and add extensions to existing nodetypes.

https://jackrabbit.apache.org/jcr/node-type-notation.html

http://www.tothenew.com/blog/custom-node-type-in-aem/

 

Basically you need to extend cq:Component node type and make it cq:Taggable mixin default applied on it.

Try extending it on your local first and then on any environment, because if you don't get it right, then it can cause issues in your repository.

Please Note - Doing so will have performance implications on your server, so do this only if it is critically needed, or else you can always resort to using X-PATH/SQL2 in finding the tagged component nodes.

- Runal