Article Mentions

Adds support for @mentions, by implementing this interface users can direct a readers attention to content in the community.

Why should I make my content mentionable?

Being able to mention content can provide users with easy access to your content. Keep in mind, you should be able to provide unique titles or it may be difficult for the user to find your content.

Creating an IMentionableContentType plugin

Adding support for @mentions is done by implementing the IMentionableContentType interface, it is defined in the Telligent.Evolution.Extensibility.Content.Version2 namespace of Telligent.Evolution.Core.dll.

It is important to note that one or more Core Services can be implemented in the same IContentType class.

Mentions are made up of three parts, first begin by returning a list of items that match a search term.

public IEnumerable<IContent> GetMentionables(string queryText, MentionableContext filter)
{
    var links = new List<IContent>();

    var results = LinksData.ListLinks()
            .Where(r => r.Name.ToLowerInvariant().Contains(queryText.ToLowerInvariant()))
            .ToList<IContent>();

    foreach (var result in results)
    {
        var content = LinksData.GetLink(result.ContentId);
        if (content != null)
        {
            links.Add(content);
        }
    }

    return links;
}

Next add a preview for your item. This sample returns literal strings but if you have implemented ITranslatablePlugin use the ITranslatablePluginController to make the results translatable.

public string GetMentionPreviewHtml(Guid contentId, MentionPreviewOptions options)
{
    if (!string.IsNullOrEmpty(options.LabelHtml))
        return options.LabelHtml;

    var content = LinksData.GetLink(contentId);
    if (content != null)
        return content.HtmlName("Web");

    return null;
}

Finally you must create the full HTML view for the mention. Here a link is created to redirect the user to your content, make sure to add these classes internal-link and view-application in your anchor tag.

public string GetMentionViewHtml(Guid contentId, MentionViewOptions options)
{
    var content = LinksData.GetLink(contentId);
    if (content != null)
    {
        if (!string.IsNullOrEmpty(content.Url))
        {
            return string.Concat("<a href=\"",
                Apis.Get<IHtml>().Encode(content.Url),
                "\" class=\"internal-link view-application links\" data-linkid=\"",
                content.ContentId, "\">", content.Name, "</a>");
        }

        return content.Name;
    }

    return null;
}

Shortcut for Indexed Content Types

If the content type already supports being indexed by search by implementing ISearchableContentType , mention support can be added easier by implementing IIndexedMentionableContentType (v2) . The only difference between IMentionableContentType and IIndexedMentionableContentType is that IIndexedMentionableContentType does not require the implementation of a method to retrieve mention suggestions--because the content is already in the search index, Verint Community will generate a query to find mentionable content of this type directly from the search index.