Displaying widgets in the CK Editor

Tracey Penberthy asked on June 5, 2017 15:58

Hi

When you add a widget via the CK Editor a cog icon gets displayed in the editor. Is there any way of rendering the html of the widget in the editor instead?

Or failing that is there a way of rendering something a bit more descriptive of what the widget represents instead of the cog icon?

I suspect not but thought I would ask

Cheers Tracey

Correct Answer

Anton Grekhovodov answered on June 6, 2017 14:45

It's possible to do, but of course it's not trivial task. You just need to resolve inline controls via the method above and then add their HTML to CKEditor. But I think it may break something. And I see other problems: how will you manage widget properties, what happend if user change something inside widget markup and you will need to write some code to save the correct data when user clicks Save button. Think over your task and try to find compromise.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Trevor Fayas answered on June 5, 2017 18:17

Sadly not, but i too wish we could get a HTML rendering. Would take a bit of programming to accomplish (would almost need to do a client-side ajax call to some resource that would take the inline widget code, render it, then return the html and insert....which may be pretty cool).

There was a request in a "Request a feature" but looks like it didn't make it.

http://ideas.kentico.com/forums/239189-kentico-product-ideas/suggestions/5348526-widget-preview-edit-mode

0 votesVote for this answer Mark as a Correct answer

Tracey Penberthy answered on June 5, 2017 18:21

Thanks for confirming that Trevor

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on June 5, 2017 18:50

No problem, please mark answers as answered so it closes out!

May have to try to build in that functionality sometime...would be a fun little challenge.

0 votesVote for this answer Mark as a Correct answer

Anton Grekhovodov answered on June 6, 2017 10:04

It's not a good idea to do it via Ajax calls. It's possible to resolve inline widget in code behind file of control, because inline widgets are saved as specific K# macro and you can resolve it via CMS.ExtendedControls.ControlHelper.ResolveDynamicControls method (example of code CMS\CMSModules\PortalEngine\Controls\Editable\EditableText.ascx.cs). Also, there is an article Resolving the inline controls for old Kentico versions, but the solution is the same for the new ones.

0 votesVote for this answer Mark as a Correct answer

Tracey Penberthy answered on June 6, 2017 12:10

Thanks Anton

I have read that article and used that method to properly render on the page any custom controls that have been added as widgets via the CK Editor.

But I don't think this solves the issue I am having, I am talking about the controls as they are rendered actually in the CK editor itself.

0 votesVote for this answer Mark as a Correct answer

Tracey Penberthy answered on June 6, 2017 14:58

OK thanks Anton

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on June 6, 2017 16:17

I was wrong then, and learned something new, thanks Anton!

0 votesVote for this answer Mark as a Correct answer

Anton Grekhovodov answered on June 6, 2017 17:01

You're welcome, guys) I hope it helps)

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.