Links in CKEditor break when saving page in Kentico 12

Vardan Hovsepyan asked on April 19, 2019 21:37

I've implemented CKEditor in a Kentico 12 MVC solution and when adding links the first time the links work ok, I add something to editor and save the page again the links are broken now.

Example:

  1. In editor I add following link with url "/current-students"
  2. Save and refresh the frontend site, and the link works ok
  3. Open the page in admin and view editor source. The previous link became something like this /cmsctx/pv/administrator/culture/en-US/wg/2635284e-e511-4619-beb0-9cd1684da7e2/readonly/0/ea/1/h/2fc5dec1fca92a7ef075526d4c1f4b85ca694da8a8c8720aa4f01087656f73f8/-/current-students?uh=3e5fe0dc28406ba9a883f768953be0cd3ecdab4395006f31ece356c18fa8d135&administrationdomain=http%3A%2F%2F[admin site domain here]
  4. Add some text to editor and save
  5. View the link in frontend page, it's broken. The new url is something like this http://[frontend site domain here]/cmsctx/pv/administrator/culture/en-US/wg/2635284e-e511-4619-beb0-9cd1684da7e2/readonly/0/ea/1/h/2fc5dec1fca92a7ef075526d4c1f4b85ca694da8a8c8720aa4f01087656f73f8/-/current-students?uh=3e5fe0dc28406ba9a883f768953be0cd3ecdab4395006f31ece356c18fa8d135&administrationdomain=http%3A%2F%2F[admin site domain here]

Anyone has an idea on how to fix this?

Recent Answers


Rui Wang answered on April 22, 2019 23:44

Are you trying to implement a CKEditor widget? The URL with /cmsctx/pv ... is the preview link that you would get under the page Property tab. It's really strange how that would get. Are you using any kind of API for preview or basically that link was really saved.

0 votesVote for this answer Mark as a Correct answer

Vardan Hovsepyan answered on April 22, 2019 23:48 (last edited on April 22, 2019 23:51)

Yes, this is a CKEditor widget. This is the link I get after saving the page for the first time and opening the source of the editor.

One more detail, this doesn't happen to document and image links, just pages

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on April 23, 2019 09:39

Not sure if it's related but I've seen a similar issue (but with preview) when the macro hash salt is different.

Can you verify the CMSHashStringSalt value in the web.config on both sides (so site and cms)?

<add key="CMSHashStringSalt" value="..." />

In case you change it you can globally re-sign macros in 'System -> Macros -> Signatures'. Using current salt.

0 votesVote for this answer Mark as a Correct answer

Tim Lemke answered on June 21, 2019 16:44

Hi Vardan,

I am having the same issue, have you found a solution?

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on June 21, 2019 16:53

Could it be related to hotfix 26?

https://devnet.kentico.com/download/hotfixes

12.0.26 - MVC - Page links incorrectly created with absolute URLs in rich text fields

The 'Insert link' dialog, available in the editor for rich text fields on the 'Content' tab of content-only pages, incorrectly created page links with absolute URLs, including the site's scheme, domain and application path (i.e. the site's 'Presentation URL'). This could cause broken links when transferring content between different environments, for example using staging. After applying the hotfix, the editor creates page links with virtual relative URLs ('/'). Additionally, the hotfix introduces an output filter that automatically resolves all relative URLs on the side of the MVC live site (based on the environment where the site is actually running). See the hotfix instructions for more information.

0 votesVote for this answer Mark as a Correct answer

Vardan Hovsepyan answered on June 21, 2019 16:54 (last edited on June 21, 2019 16:56)

Hi Tim,

In the editor add a "~" in front of the links, so the links become ~/page1/page2. Then in the view do something like this: @Html.Kentico().ResolveUrls(Model.Text).

Hope it helps.

1 votesVote for this answer Mark as a Correct answer

Tim Lemke answered on June 21, 2019 16:56

Hi David,

Could be! I am applying the hotfix now to see if it resolves the issue.

Also thanks Vardan, I will try that!

0 votesVote for this answer Mark as a Correct answer

Tim Lemke answered on June 21, 2019 20:01

Hi David and Vardan,

After applying the hotfix I needed to opt-out from the Automatic URL Resolving and implement the solution your proposed Vardan.

Thanks for your help!

Regards,

Tim

0 votesVote for this answer Mark as a Correct answer

Tim Lemke answered on June 21, 2019 22:53

Hi Vardan,

Since implementing your solution, images added with the CKEditor now longer display correctly in the page tab but correctly on the Front End. Did you find a workaround for this?

Regards, Tim

0 votesVote for this answer Mark as a Correct answer

Vardan Hovsepyan answered on June 24, 2019 22:32

Hi Tim,

For the files (image, document, etc...) you don't need to prepend a tilde in front of the url. When kentico detects the url points to a file, it doesn't transform it like it does for the pages.

0 votesVote for this answer Mark as a Correct answer

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