<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Mentions</title><link>https://community.telligent.com/community/11/w/developer-training/65105/mentions</link><description /><dc:language>en-US</dc:language><generator>14.0.0.586 14</generator><item><title>Mentions</title><link>https://community.telligent.com/community/11/w/developer-training/65105/mentions</link><pubDate>Tue, 04 Aug 2020 21:27:45 GMT</pubDate><guid isPermaLink="false">b4d5b17f-12e6-44aa-9393-689fd871e525</guid><dc:creator>Former Member</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/65105/mentions#comments</comments><description>Current Revision posted to Developer Training by Former Member on 08/04/2020 21:27:45&lt;br /&gt;
&lt;p&gt;Adds support for @mentions, by implementing this interface users can direct a readers attention to content in the community.&lt;/p&gt;
&lt;h3&gt;&lt;a id="Why_should_I_make_my_content_mentionable" name="Why_should_I_make_my_content_mentionable"&gt;&lt;/a&gt;Why should I make my content mentionable?&lt;/h3&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;h3&gt;&lt;a id="Creating_an_IMentionableContentType_plugin" name="Creating_an_IMentionableContentType_plugin"&gt;&lt;/a&gt;Creating an IMentionableContentType plugin&lt;/h3&gt;
&lt;p&gt;Adding support for @mentions is done by implementing the [[api-documentation:IMentionableContentType Plugin Type|IMentionableContentType]] interface, it is defined in the &lt;code&gt;Telligent.Evolution.Extensibility.Content.Version1&lt;/code&gt; namespace of &lt;code&gt;Telligent.Evolution.Core.dll&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It is important to note that one or more Core Services can be implemented in the same [[api-documentation:IContentType Plugin Type|IContentType]] class.&lt;/p&gt;
&lt;p&gt;Mentions are made up of three parts, first begin by returning a list of items that match a search term.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;public IEnumerable&amp;lt;IContent&amp;gt; GetMentionables(int userId, string queryText, IMentionableFilter filter)
{
    var links = new List&amp;lt;IContent&amp;gt;();

    var results = LinksData.ListLinks()
            .Where(r =&amp;gt; r.Name.ToLowerInvariant().Contains(queryText.ToLowerInvariant()))
            .ToList&amp;lt;IContent&amp;gt;();

    foreach (var result in results)
    {
        var content = LinksData.GetLink(result.ContentId);
        if (content != null)
        {
            links.Add(content);
        }
    }

    return links;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Next add a preview for your item. This sample returns literal strings but&amp;nbsp;if you have implemented [[api-documentation:ITranslatablePlugin Plugin Type|ITranslatablePlugin]] use the&amp;nbsp;[[api-documentation:ITranslatablePluginController Plugin Supplementary Type|ITranslatablePluginController]] to make the results translatable.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;public string GetMentionPreviewHtml(int userId, Guid contentId)
{
    try
    {
        var content = LinksData.GetLink(contentId);
        if (content != null)
        {
            return String.Format(&amp;quot;{0} (Link)&amp;quot;, content.HtmlName(&amp;quot;Web&amp;quot;));
        }

        return &amp;quot;(deleted link)&amp;quot;;
    }
    catch (Exception)
    {
        return &amp;quot;(inaccessible link)&amp;quot;;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;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 &lt;code&gt;internal-link&lt;/code&gt; and &lt;code&gt;view-application&lt;/code&gt; in your anchor tag.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;public string GetMentionViewHtml(int userId, Guid contentId)
{
    try
    {
        var content = LinksData.GetLink(contentId);
        if (content != null)
        {
            if (!string.IsNullOrEmpty(content.Url))
            {
                return string.Concat(&amp;quot;&amp;lt;a href=\&amp;quot;&amp;quot;,
                    PublicApi.Html.Encode(content.Url),
                    &amp;quot;\&amp;quot; class=\&amp;quot;internal-link view-application links\&amp;quot; data-linkid=\&amp;quot;&amp;quot;,
                    content.ContentId, &amp;quot;\&amp;quot;&amp;gt;&amp;quot;, content.Name, &amp;quot;&amp;lt;/a&amp;gt;&amp;quot;);
            }

            return content.Name;
        }

        return &amp;quot;(deleted link)&amp;quot;;
    }
    catch (Exception)
    {
        return &amp;quot;(inaccessible link)&amp;quot;;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here is the full sample.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.telligent.com/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/0815_2E00_LinkItemContentType_2E00_cs"&gt;community.telligent.com/.../0815_2E00_LinkItemContentType_2E00_cs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here is a sample of the @mention UI.&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/8883.png"&gt;&lt;img style="border:1px solid #DEDEDE;" alt=" " src="/resized-image/__size/275x191/__key/communityserver-wikis-components-files/00-00-00-12-83/8883.png" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: mentions&lt;/div&gt;
</description></item><item><title>Mentions</title><link>https://community.telligent.com/community/11/w/developer-training/65105/mentions/revision/1</link><pubDate>Thu, 13 Jun 2019 19:28:34 GMT</pubDate><guid isPermaLink="false">b4d5b17f-12e6-44aa-9393-689fd871e525</guid><dc:creator>Ben Tiedt</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/65105/mentions#comments</comments><description>Revision 1 posted to Developer Training by Ben Tiedt on 06/13/2019 19:28:34&lt;br /&gt;
&lt;p&gt;Adds support for @mentions, by implementing this interface users can direct a readers attention to content in the community.&lt;/p&gt;
&lt;h3&gt;&lt;a id="Why_should_I_make_my_content_mentionable" name="Why_should_I_make_my_content_mentionable"&gt;&lt;/a&gt;Why should I make my content mentionable?&lt;/h3&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;h3&gt;&lt;a id="Creating_an_IMentionableContentType_plugin" name="Creating_an_IMentionableContentType_plugin"&gt;&lt;/a&gt;Creating an IMentionableContentType plugin&lt;/h3&gt;
&lt;p&gt;Adding support for @mentions is done by implementing the [[api-documentation:IMentionableContentType Plugin Type|IMentionableContentType]] interface, it is defined in the &lt;code&gt;Telligent.Evolution.Extensibility.Content.Version1&lt;/code&gt; namespace of &lt;code&gt;Telligent.Evolution.Core.dll&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It is important to note that one or more Core Services can be implemented in the same [[api-documentation:IContentType Plugin Type|IContentType]] class.&lt;/p&gt;
&lt;p&gt;Mentions are made up of three parts, first begin by returning a list of items that match a search term.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;public IEnumerable&amp;lt;IContent&amp;gt; GetMentionables(int userId, string queryText, IMentionableFilter filter)
{
    var links = new List&amp;lt;IContent&amp;gt;();

    var results = LinksData.ListLinks()
            .Where(r =&amp;gt; r.Name.ToLowerInvariant().Contains(queryText.ToLowerInvariant()))
            .ToList&amp;lt;IContent&amp;gt;();

    foreach (var result in results)
    {
        var content = LinksData.GetLink(result.ContentId);
        if (content != null)
        {
            links.Add(content);
        }
    }

    return links;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Next add a preview for your item. This sample returns literal strings but&amp;nbsp;if you have implemented [[api-documentation:ITranslatablePlugin Plugin Type|ITranslatablePlugin]] use the&amp;nbsp;[[api-documentation:ITranslatablePluginController Plugin Supplementary Type|ITranslatablePluginController]] to make the results translatable.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;public string GetMentionPreviewHtml(int userId, Guid contentId)
{
    try
    {
        var content = LinksData.GetLink(contentId);
        if (content != null)
        {
            return String.Format(&amp;quot;{0} (Link)&amp;quot;, content.HtmlName(&amp;quot;Web&amp;quot;));
        }

        return &amp;quot;(deleted link)&amp;quot;;
    }
    catch (Exception)
    {
        return &amp;quot;(inaccessible link)&amp;quot;;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;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 &lt;code&gt;internal-link&lt;/code&gt; and &lt;code&gt;view-application&lt;/code&gt; in your anchor tag.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;public string GetMentionViewHtml(int userId, Guid contentId)
{
    try
    {
        var content = LinksData.GetLink(contentId);
        if (content != null)
        {
            if (!string.IsNullOrEmpty(content.Url))
            {
                return string.Concat(&amp;quot;&amp;lt;a href=\&amp;quot;&amp;quot;,
                    PublicApi.Html.Encode(content.Url),
                    &amp;quot;\&amp;quot; class=\&amp;quot;internal-link view-application links\&amp;quot; data-linkid=\&amp;quot;&amp;quot;,
                    content.ContentId, &amp;quot;\&amp;quot;&amp;gt;&amp;quot;, content.Name, &amp;quot;&amp;lt;/a&amp;gt;&amp;quot;);
            }

            return content.Name;
        }

        return &amp;quot;(deleted link)&amp;quot;;
    }
    catch (Exception)
    {
        return &amp;quot;(inaccessible link)&amp;quot;;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here is the full sample.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.telligent.com/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/0815_2E00_LinkItemContentType_2E00_cs"&gt;community.telligent.com/.../0815_2E00_LinkItemContentType_2E00_cs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here is a sample of the @mention UI.&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/8883.png"&gt;&lt;img style="border:1px solid #DEDEDE;" src="/resized-image/__size/275x191/__key/communityserver-wikis-components-files/00-00-00-12-83/8883.png" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item></channel></rss>