Verint | Telligent Community
Verint | Telligent Community
  • Site
  • User
  • Site
  • Search
  • User
Verint Community 11.x
  • Verint Community
Verint Community 11.x
Developer Training Mentions
  • User Documentation
  • Ask the Community
  • API Documentation
  • Manager Training
  • Developer Training
  • Tags
  • More
  • Cancel
  • New
  • +Getting Started
  • +External Integration
  • -Plugins/Framework extension
    • +In-Process API
    • -Plugins
      • Exceptions and Logging
      • -Plugin Examples
        • Creating Activity Stories
        • -Creating Custom Applications and Content
          • -Adding Core Service Support to Content
            • Bookmarks
            • Comments
            • Likes
            • Mentions
            • Moderation/Abuse Management
            • Search
            • +Tags
        • Defining Permissions
        • Executing Code Before Plugin Initialization
        • Exposing Configuration Options
        • Exposing Data to External Sources
        • File Viewers
        • Handling Embedded Files in Content
        • Handling Events
        • Interacting With Files
        • Managing Dependencies
        • Managing Physical File Storage
        • Notifications
        • Registering Tokens for Templates
        • Template-based Email
        • Translating Plugin Text
        • Using Widgets to Render Content From Plugins
      • Plugin Lifecycle
    • +Setting Up Your Development Environment
  • +Automations
  • +UI Customization
  • +Scripting

You are currently reviewing an older revision of this page.

  • History View current version

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.Version1 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(int userId, string queryText, IMentionableFilter 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(int userId, Guid contentId)
{
    try
    {
        var content = LinksData.GetLink(contentId);
        if (content != null)
        {
            return String.Format("{0} (Link)", content.HtmlName("Web"));
        }

        return "(deleted link)";
    }
    catch (Exception)
    {
        return "(inaccessible link)";
    }
}

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(int userId, Guid contentId)
{
    try
    {
        var content = LinksData.GetLink(contentId);
        if (content != null)
        {
            if (!string.IsNullOrEmpty(content.Url))
            {
                return string.Concat("<a href=\"",
                    PublicApi.Html.Encode(content.Url),
                    "\" class=\"internal-link view-application links\" data-linkid=\"",
                    content.ContentId, "\">", content.Name, "</a>");
            }

            return content.Name;
        }

        return "(deleted link)";
    }
    catch (Exception)
    {
        return "(inaccessible link)";
    }
}

Here is the full sample.

Fullscreen 0815.LinkItemContentType.cs Download
using System;
using System.Collections.Generic;
using System.Linq;
using Telligent.Evolution.Extensibility;
using Telligent.Evolution.Extensibility.Api.Version1;
using Telligent.Evolution.Extensibility.Content.Version1;
using IContent = Telligent.Evolution.Extensibility.Content.Version1.IContent;

namespace Samples.Links
{
    public class LinkItemContentType : IContentType, IMentionableContentType
    {
        IContentStateChanges _contentState = null;

        #region IPlugin Members

        public string Description
        {
            get { return "Items in a Links collection"; }
        }

        public void Initialize()
        {
        
        }

        public string Name
        {
            get { return "Link Items"; }
        }
        
        #endregion

        #region IContentType Members

        public Guid[] ApplicationTypes
        {
            get { return new Guid[] { ContentTypes.LinksApplicationId }; }
        }

        public void AttachChangeEvents(IContentStateChanges stateChanges)
        {
            _contentState = stateChanges;
        }

        public Guid ContentTypeId
        {
            get { return ContentTypes.LinksItemId; }
        }

        public string ContentTypeName
        {
            get { return "Links Item"; }
        }

        public IContent Get(Guid contentId)
        {
            return LinksData.GetLink(contentId);
        }

        #endregion

        #region IMentionableContentType

        public IEnumerable<IContent> GetMentionables(int userId, string queryText, IMentionableFilter 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;
        }

        public string GetMentionPreviewHtml(int userId, Guid contentId)
        {
            try
            {
                var content = LinksData.GetLink(contentId);
                if (content != null)
                {
                    return String.Format("{0} (Link)", content.HtmlName("Web"));
                }

                return "(deleted link)";
            }
            catch (Exception)
            {
                return "(inaccessible link)";
            }
        }

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

                    return content.Name;
                }

                return "(deleted link)";
            }
            catch (Exception)
            {
                return "(inaccessible link)";
            }
        }

        #endregion
    }
}

Here is a sample of the @mention UI.

  • Telligent
  • Professional Services
  • Submit a Support Ticket
  • Become a Partner
  • Request a Demo
  • Contact Us

About
Privacy Policy
Terms of use
Copyright 2024 Verint, Inc.
Powered by Verint Community