loadTagNamespaces in /libs/cq/tagging/widget.js is loading the tagNamespaces wrongly when I give tagsBasePath as /etc/tags/facebook/work for xtype:tags? | Community
Skip to main content
October 16, 2015
Solved

loadTagNamespaces in /libs/cq/tagging/widget.js is loading the tagNamespaces wrongly when I give tagsBasePath as /etc/tags/facebook/work for xtype:tags?

  • October 16, 2015
  • 4 replies
  • 1819 views

Hello Team,

I have a requirement to show up the tags only for tag path /etc/tags/facebook/work. I played with tagsBasePath as /etc/tags/facebook/work to get only facebook work tags displayed. But when I click on the tag to get added, tag is not getting added. When I digged into the code, I am seeing the following error. I am not sure If I should not change the tagsBasePath and please help me how to achieve my functionality.

  1. Uncaught TypeError: Cannot read property 'name' of undefined widgets.js:1573
    1. CQ.tagging.TagInputField.CQ.Ext.extend.checkMaximumwidgets.js:1573
    2. CQ.tagging.TagInputField.CQ.Ext.extend.addTagwidgets.js:1028
    3. CQ.tagging.TagInputField.CQ.Ext.extend.toggleTagwidgets.js:1543
    4. CQ.tagging.TagInputField.CQ.Ext.extend.onTagNodeClickedwidgets.js:2106
    5. EXTUTIL.Event.firewidgets.js:4776
    6. EXTUTIL.Observable.fireEventwidgets.js:4417
    7. CQ.Ext.tree.TreePanel.CQ.Ext.extend.proxyNodeEventwidgets.js:58445
    8. CQ.Ext.data.Node.CQ.Ext.extend.fireEventwidgets.js:59747
    9. CQ.Ext.tree.TreeNodeUI.CQ.Ext.extend.fireEventwidgets.js:61206
    10. CQ.Ext.tree.TreeNodeUI.onClickwidgets.js:87770
    11. CQ.Ext.tree.TreeEventModel.onNodeClickwidgets.js:59075
    12. CQ.Ext.tree.TreeEventModel.delegateClickwidgets.js:59035

 loadTagNamespaces: function() {

        this.tagNamespaces = {};
        var tagJson = this.loadJson(this.tagsBasePath + CQ.tagging.TAG_LIST_JSON_SUFFIX + "?count=false");
        if (tagJson && tagJson.tags) {
            CQ.Ext.each(tagJson.tags, function(t) {
                this.tagNamespaces[t.name] = t;
            }, this);
        }

         this.setupPopupMenu();

        this.tagNamespacesLoaded = true;
    }

facebook:work/employer/305115773870 -- nsTagId

getNamespaceDefinition: function(nsTagID) {
        if (!this.tagNamespacesLoaded) {
            this.loadTagNamespaces();
        }
        
        var nsName = CQ.tagging.parseTagID(nsTagID).namespace;
        return this.tagNamespaces[nsName];
    }

Here as a result : I am getting the getNamespaceDefinition function returning the value as undefined.

checkMaximum: function(tag) {
        var ns;
        
        if (typeof tag === "string") {
            // new tag
            if (this.displayTitles) {
                ns = this.getNamespaceDefinitionByTitlePath(tag);
            } else {
                ns = this.getNamespaceDefinition(tag);
            }
        } else {
            // existing tag
            ns = this.getNamespaceDefinition(tag.tagID);
        }
        
        if (ns === null) {
            // if the namespace is not found, we can't change for a maximum and have to accept it
            return true;
        }
     
        var cfg = this.getNamespaceConfig(ns.name); -- ns.name of undefined is giving the above error for which I have provided the stack trace.

...

}

values that I got out of debug:

nsTagID
"facebook:work/employer/305115773870"
nsName
"facebook"
this.tagNamespaces
 
Object {employerObjectlocationObjectpositionObject}
  1. employerObject
    1. descriptionnull
    2. description_xss""
    3. lastModified0
    4. lastModifiedBynull
    5. name"employer"
    6. path"/etc/tags/facebook/work/employer"
    7. pubDate""
    8. publisher""
    9. replicationObject
    10. tagID"facebook:work/employer"
    11. title"Employer"
    12. titlePath"Facebook : Work / Employer"
    13. __proto__Object
  2. locationObject
    1. descriptionnull
    2. description_xss""
    3. lastModified0
    4. lastModifiedBynull
    5. name"location"
    6. path"/etc/tags/facebook/work/location"
    7. pubDate""
    8. publisher""
    9. replicationObject
    10. tagID"facebook:work/location"
    11. title"Location"
    12. titlePath"Facebook : Work / Location"
    13. __proto__Object
  3. positionObject
    1. descriptionnull
    2. description_xss""
    3. lastModified0
    4. lastModifiedBynull
    5. name"position"
    6. path"/etc/tags/facebook/work/position"
    7. pubDate""
    8. publisher""
    9. replicationObject
    10. tagID"facebook:work/position"
    11. title"Position"
    12. titlePath"Facebook : Work / Position"
    13. __proto__Object
  4. __proto__Object

Best Regards,

Durga

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by PaulMcMahon

Ah - out of the box there is no way to achieve your requirement - you'd have to create a new workspace and put those tags in that workspace. 

Or you'd have to extend the tag input widget and add the filtering capability. 

4 replies

Level 8
October 16, 2015

You don't want to use the tagsBasePath property - you want to use the namespaces property. It's an array of strings representing the namespaces you want to be displayed. See http://dev.day.com/docs/en/cq/current/widgets-api/index.html?class=CQ.tagging.TagInputField for details. You wold set the property to facebook in your case. 

October 16, 2015

Thanks Paul for your reply. I tried the namespaces property also. But all the tags are maintained under one namespace facebook. I have attached the screenshot for your reference.

My requirement is to refine/display the certain tags with in the name space. for eg: /etc/tags/facebook/work

PaulMcMahonAccepted solution
Level 8
October 16, 2015

Ah - out of the box there is no way to achieve your requirement - you'd have to create a new workspace and put those tags in that workspace. 

Or you'd have to extend the tag input widget and add the filtering capability. 

October 16, 2015

Thanks Paul for your suggestion. Even I am thinking of extending the CQ.tagging.TagInputField