elliot-sawyer / silverstripe-linkfield

Adds a Linkfield for gorriecoe/silverstripe-link
BSD 3-Clause "New" or "Revised" License
9 stars 25 forks source link

Dropdown for choosing an anchor #10

Open wernerkrauss opened 5 years ago

wernerkrauss commented 5 years ago

When linking to a page in the CMS it would be handy to choose from the existing anchors in a dropdown.

I think I've seen this in the TinyMCE link widged.

wernerkrauss commented 5 years ago

Related issue: https://github.com/silverstripe/silverstripe-cms/issues/2440

gorriecoe commented 4 years ago

@wernerkrauss I have been thinking about this and my ideal solution would be to add a field to Sitetree that stores a serialized list of anchor. These anchors can then be registered by some sort of method i.e addExtraAnchor('nameHere') on SiteTree. Then with a getter i.e getAnchors() I could get a list of anchors and put them in a dropdown. This means that anchors from modules such as Elemental could be listed. Sitetree could use beforeWrite to check the content field and register anchors found in the field.

GuySartorelli commented 3 years ago

There is already a ticket raised in Elemental to get it to work with the existing anchor link functionality in SilverStripe - I recommend against making a workaround for modules which don't use the existing anchor extension point. Anchors on a page can already be accessed using getAnchorsOnPage which already has an extension point updateAnchorsOnPage.

wernerkrauss commented 1 year ago

The issue @GuySartorelli talked about is now solved and ready to use ;) https://github.com/silverstripe/silverstripe-elemental/issues/186