Ephox custom control

Is there a way to write a custom control in ephox, which utilizes the working of inline link, but instead of creating a hyperlink to the targeted content item, it reads a specific field of the targeted content item and displays it in the ephox editor.


Hi Manvinder

Isn’t this just an inline template?


Hello Jimbo,

No it is not inline template or even inline link. Let me give an example to make it clear.

I have a content type (Sponsor), which has URL and address fields.
I created a content item (Sponsor1), with the values www.google.com and California.

I have another content type, Event, which has Name and Body as fields.
When creating a Event content item, I want to have a link in the body which points to the Sponsor1’s URL.
For e.g my body should be like
click here to learn about the sponsor and this link should point to www.google.com, which is the URL in sponsor1 content item.

When I use inline link or inline template, click here to learn about the sponsor , link points to sponsor1 content item and not to the URL of the sponsor1 content item.
This would require me to do additional processing of reading the sponsor1 URL field and create a hyperlink for it. Is there any way to do it with OOTB functionalities? Or do I need to create a new custom control and if so, can I leverage inline link’s functionalities and do additional processing.

It is just an inline template. You can do this by creating a snippet template set up to assemble your Sponsor content type, which just retrieves the URL field and sticks it in an a tag as the href attribute, with the text “click here to learn about the sponsor”, then add the snippet template as a new line in the Allowed Content list of the sys_inline_variant slot, as one of the options for assembling Sponsor items. The tricky part is how to make it usable for your authors/editors. When searching for a Sponsor item to add as an inline variant, they will have to find the checkbox for the item they want, but also make sure they choose the checkbox that corresponds to the item as assembled by your new snippet template. We long ago decided this was ridiculously poor from a usability point of view, which is why I set up a dispatch snippet template, which is used for all content types (except images) in all slots, including sys_inline_variant. It makes the EditLive interface less WYSIWYG, but at least we aren’t dependent on all our different users’ selection of which template to use in each situation, and the choice isn’t hardcoded, limiting future redesigns. But to use this method, you need to be able to programmatically decide which actual snippet template to use, and encode that logic in the bindings of the dispatch snippet template. I don’t know of a way to tell which field an inline variant snippet is being assembled as part of (I’d be very interested if anyone finds a way) but you can determine the content type of the page it is being added to, and the type of the item being assembled. So if all Sponsor items should be displayed the same way on all Event pages, then you can use this technique.