Anchor to content element

Hi everyone,

is there a way to use the concept of anchors in Neos?
I would like to create a link from another page to a defined content element.
Example: By clicking the link, I’m directed to the new page and automatically scroll to the middle of the page where the defined content element is located.

Thank you
DanielOliver

Hey @DanielOliver ,

you can extend the target elements inspector and add a input field where you can define a anchor name.

Edit the roots.ts2 ( add something like: anchorId = ${q(node).property(‘anchorId’)} )
Edit your template:

<f:if condition='{anchorId}'>
	<a name="{anchorId}"></a>
</f:if>

Now you have to use JavaScript.
Maybe this will help: http://stackoverflow.com/questions/13735912/anchor-jumping-by-using-javascript

I hope this will help! :grinning:

1 Like

+1 for getting a solution in the core, I’ve had customers request this in almost every project.

1 Like