Restrict evolutionComposer mentions to certain content types?

Developer Space

Developer Space
Want to extend the Telligent Evolution platform? Collaborate with other developers and product experts here.

Restrict evolutionComposer mentions to certain content types?

This question is answered

Is there a way to restrict the content types that an evolutionComposer configured for the mentions plugin returns?

For example, restrict it so you can only mention Groups or Users, nothing else.

Verified Answer
  • The retrieval of mentionables is defined by the onMentionalList method implementation on the mentions composer plugin.  The default implementation is below and can be modified and applied as an override:

    $.fn.evolutionComposer.plugins.mentions.defaults = {

    onMentionableList: function(query, complete) {

    $.telligent.evolution.get({

    url: $.telligent.evolution.site.getBaseUrl() + 'api.ashx/v2/mentionables.json?IncludeFields=Token,PreviewHtml',

    data: {

    QueryText: query,

    PageSize: 20

    },

    cache: false,

    dataType: 'json',

    success: function(response) {

    if(response.Mentionables && response.Mentionables.length > 0) {

    var results = $.map(response.Mentionables, function(mentionable) {

    return { name: mentionable.PreviewHtml, token: mentionable.Token };

    });

    complete(results);

    } else {

    complete(null);

    }

    }

    });

    }

    };

    Note that the REST endpoint for mentionables does enable filtering, but only of a single type.  To implement support for only two content types, you'd need to issue two queries and combine the results.

All Replies
  • The retrieval of mentionables is defined by the onMentionalList method implementation on the mentions composer plugin.  The default implementation is below and can be modified and applied as an override:

    $.fn.evolutionComposer.plugins.mentions.defaults = {

    onMentionableList: function(query, complete) {

    $.telligent.evolution.get({

    url: $.telligent.evolution.site.getBaseUrl() + 'api.ashx/v2/mentionables.json?IncludeFields=Token,PreviewHtml',

    data: {

    QueryText: query,

    PageSize: 20

    },

    cache: false,

    dataType: 'json',

    success: function(response) {

    if(response.Mentionables && response.Mentionables.length > 0) {

    var results = $.map(response.Mentionables, function(mentionable) {

    return { name: mentionable.PreviewHtml, token: mentionable.Token };

    });

    complete(results);

    } else {

    complete(null);

    }

    }

    });

    }

    };

    Note that the REST endpoint for mentionables does enable filtering, but only of a single type.  To implement support for only two content types, you'd need to issue two queries and combine the results.