Is it possible to alter the content that appears in the popup of the new peekable content?
Is it possible to alter the content that appears in the popup of the new peekable content?
Yes, there are widgets that define the UI for the peek for each type of content.
In Widget Studio, you will need to select the Content or Application type from the "Viewing" dropdown. Once selected you should see the widget that defines the peek.
So if I have a custom content type, do I need to define it's peek widget somehow as well?
Yes, you can implement IPeekableContentType Plugin Type to define the content, including specifying a widget to render via IScriptablePlugin Plugin Type .
More details here: Using Widgets to Render Content From Plugins
Perfect, Thanks Steven
Steven, looks like the GetViewHtml is called in my IContentType when the Peek is firing...I already had code defined in there so how can I tell if the request is a peek or if it is something else?
My custom content type already implements ISearchableContentType - which also requires GetViewHtml - so what do I do to ensure when the peek is fired, it loads my custom widget, and when it is called from within a search context, it shows something else?
You can implement the interfaces explicitly to ensure the correct method is called for each interface.
string IPeekableContentType.GetViewHtml(IContent content, Target target)
- Thanks. That worked. Once we're in that widget, how do we get access to the underlying content object? I see in the other widgets it is doing something like #set ($content = $context.Content)
#if (!$content)
$core_v2_widget.Hide()
#end
How do we populate our own $context object?
You will need to create your own private widget API. See the section on Defining private widget APIs in Using Widgets to Render Content From Plugins .
When you are rendering your widget in the GetViewHtml, you can pass the contentId and contentTypeId into the widget and the private api can use those to populate the Content object:
return WidgetController.RenderContent(_peekableContentFragmentId, new NameValueCollection { ["contentTypeId"] = content.ContentTypeId.ToString(), ["contentId"] = content.ContentId.ToString(), ["target"] = target.ToString() });
Your private API would look something like this:
public class PanelContext : IContextualScriptedContentFragmentExtension { public string ExtensionName { get { return "context"; } } public object GetExtension(NameValueCollection context) { Guid contentId; Guid contentTypeId; if (!Guid.TryParse(context["contentId"], out contentId)) contentId = Guid.Empty; if (!Guid.TryParse(context["contentTypeId"], out contentTypeId)) contentTypeId = Guid.Empty; return new PanelContextApi(contentId, contentTypeId, context["target"] ?? "Web"); } } public class PanelContextApi { public PanelContextApi(Guid contentId, Guid contentTypeId, string target) { Content = Telligent.Evolution.Extensibility.Apis.Get<IContents>().Get(contentId, contentTypeId); Target = target; } public Telligent.Evolution.Extensibility.Api.Entities.Version1.Content Content { get; } public string Target { get; } }
Ok, thanks. The $context being a widget extension threw me off since it didn't have a "core_v2_etc..."