Can the IPeekableContentType view just return HTML (not working), or does it need to be a widget?

Hi all,

I have a custom content type implemented with support for both IReindexableSearchableContentType and IIndexedMentionableContentType.  Both searching and @mentioning the content type works as expected.

Now I'm trying to implement IPeekableContentType, and having some difficulty.  I wanted to take the easy way out and implement it with some hard-coded HTML, like this below.

string IPeekableContentType.GetViewHtml(IContent content, Target target)
{
    var product = ProductsData.GetProduct(content.ContentId);
    string result = string.Format("<div style=\"background:yellow; padding:20px; border:2px solid black;\"><a style=\"font-size:120px; font-weight:bold;\" href=\"{0}\">{1}</a></div>", product.Url, product.Name);
    
    // log method name, parameters, and result
    Log(string.Format("IPeekableContentType.GetViewHtml({0}, {1}) => {2}", content.ContentId, target, result));

    return result;
}

For testing I am creating a new Blog Post and using the @mention function to mention the one of the custom content items.  That all works.  But when I hover over the link there is no pop-up, and in looking at the logs I don't even see the GetViewHtml() method being called.

I checked the widget in the footer and all content types are enabled for the hover.

What am I missing?

Does GetViewHtml have to implemented as a Widget, or is Html ok too?

Thanks in advance.

Parents
  • This is solved, but for anyone else in the same spot the issue was with the rendering of the mention in the content, and not the rendering of the peekable.

    In `GetMentionViewHtml(Guid contentId, MentionViewOptions options)` I was just rendering a link in the content, but I needed to also include an embedded contentTypeId, contentId, and the `ui-contentpeek` CSS class.

    So this didn't work...

    public string GetMentionViewHtml(Guid contentId, MentionViewOptions options)
    {
        var product = ProductsData.GetProduct(contentId);
    
        return string.Format("<a style=\"color:red\" href=\"{0}\">{1}</a>", 
            product.Url, product.Name);
    }

    But this does...

    public string GetMentionViewHtml(Guid contentId, MentionViewOptions options)
    {
        var product = ProductsData.GetProduct(contentId);
    
        return string.Format("<a data-contentid=\"{0}\" data-contenttypeid=\"{1}\" class=\"ui-contentpeek\" style=\"color:red\" href=\"{2}\">{3}</a>", 
            contentId.ToString("N"),
            ContentTypes.ProductItemContentTypeId.ToString("N"),
            product.Url, product.Name);
    }

    P.S. - I didn't see this mentioned anywhere in the documentation.  If there is, please provide a link.

Reply
  • This is solved, but for anyone else in the same spot the issue was with the rendering of the mention in the content, and not the rendering of the peekable.

    In `GetMentionViewHtml(Guid contentId, MentionViewOptions options)` I was just rendering a link in the content, but I needed to also include an embedded contentTypeId, contentId, and the `ui-contentpeek` CSS class.

    So this didn't work...

    public string GetMentionViewHtml(Guid contentId, MentionViewOptions options)
    {
        var product = ProductsData.GetProduct(contentId);
    
        return string.Format("<a style=\"color:red\" href=\"{0}\">{1}</a>", 
            product.Url, product.Name);
    }

    But this does...

    public string GetMentionViewHtml(Guid contentId, MentionViewOptions options)
    {
        var product = ProductsData.GetProduct(contentId);
    
        return string.Format("<a data-contentid=\"{0}\" data-contenttypeid=\"{1}\" class=\"ui-contentpeek\" style=\"color:red\" href=\"{2}\">{3}</a>", 
            contentId.ToString("N"),
            ContentTypes.ProductItemContentTypeId.ToString("N"),
            product.Url, product.Name);
    }

    P.S. - I didn't see this mentioned anywhere in the documentation.  If there is, please provide a link.

Children