TinyMCE: Linking to Anchor on Another Internal Page

Hi! I'm just wondering if there's an easy way for non-technical users to create links to anchors on a different internal page than the one they're on from the TinyMCE editor in Plone 5.2.1.

The ability to insert internal links is great, as is the ability to insert links to anchors on the current page, but I can't see a way to do the intersection of them both other than hand-editing the source code to insert a named anchor on the one element and then add the anchor to the end of the link in the other element. That's something I could certainly do, but I'm aiming to teach very non-technical people to create and maintain documents on the site.

(I did enable the Anchor plugin for TinyMCE and add it to the toolbar. This allows you to set anchor points, but not link to them from other pages. I also noticed that even manually adding the anchor to the HTML doesn't work unless you link to the page directly instead of using the default "resolve" link that Plone inserts, which of course would disable a bunch of useful Plone functionality, like following the target around if you moved the page, etc.)

What happens if you set the internal link and switch to html source code. append the anchor to the uri resolveuid/xxx/#anchorname

I had tried that previously but without the / between the resolve address and the anchorname -- resolveuid/xxx#anchorname rather than your proposed format. Mine didn't work, but yours does! That's cool for me, but I don't think it's something I could reasonably count on non-technical people to do (or at least, to not be alarmed by). I'm trying to avoid them having to hand-edit code as much as possible.

we have the same problem, but not a solution. but non-technicals don't knows about anchors :wink:

1 Like

At least the anchor plugin allows creating named anchors easily, even if it doesn't allow linking to them from another document easily. It's a start, I suppose. :slight_smile:

We came across this issue with an editor recently, where they were wanting to link to an anchor tag on another page on the same site. Further complicating this was TinyMCE's default behavior to convert URLs to relative (why?) when loaded, and doing a poor job of it. A link to "https://mysite.org/my/site/page1#header4" would turn into something like "../page1#header4" on second edit, and then render as "https://mysite.org/my/page1#header4" - a broken link. This is probably only an issue if your site root is not on the domain root.

We are testing this setting in the advanced settings:

{"relative_urls": false, "remove_script_host"}

This still requires using the External tab in the editor, but stops TinyMCE from mucking up the URL at least. So far it does not appear to have any adverse side effects.