5

I need to link to a particular #anchor on a page from within the WYSIWYG editor.

However, if I start by using Link to Entry in the Rich Text editor, Redactor adds its own 'anchor' (with the same syntax as the Reference Tag for the entry page), and any additional anchors I add to the URL using the Edit Source functionality are ignored.

How would you suggest creating enabling users to create links to specific parts of Entry pages from within the Rich Text editor?

4

As of Craft 2.5.2759 this is now possible.

It is now possible to include custom URL fragments in links to entries within Rich Text fields, alongside the entry's reference fragment (e.g. href="my-entry#custom-fragment#entry:123").

| improve this answer | |
1

This is more of a workaround than a truly official method. The #entry:id you are seeing is more of a reference for Craft to figure out the correct URL when you edit the entry later. If you were to look at the link live, you would notice that the hash is missing.

The workaround is to create a link to an entry. Then, either save and return or toggle Edit Source. When you return, you can click on the link to find a tiny popup giving you the option to Edit or Unlink. When you edit, you can change the hash to anything you like. It should save just fine.

| improve this answer | |
  • Yes, I tried that — Unfortunately, without the Reference Tag syntax in the hash, Craft stops treating the link as a Link to Entry and simply treats it like a static link. (As long as you keep the Reference Tag syntax in the hash, Craft converts the link into an actual (Reference Tag)[buildwithcraft.com/docs/reference-tags] when it stores the content in the database, so the link will remain relative to the proper siteUrl when it's parsed in the template.) I need the link to be self-updating across environments. – Michael Rog Apr 3 '15 at 4:09
  • Yes. That's not built in, and why I called this a workaround. It could probably be done with a plugin. A Link to Entry Anchor if you will. – Bryan Redeagle Apr 3 '15 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.