I am using Sulu as CMS and I want to add an internal link to the main navigation, but the browser should scroll to a specific section of the page.

I do not see any way to add the "#..." part to the internal link.

As a workaround I can use an external link, where I can specify the complete URL. But I prefer using the internal link feature.

Any ideas? I have installed Sulu 2.5.10.

1

There are 1 answers

0
stollr On

In Sulu's slack channel I got the answer that this is currently not possible.

So I stick with the workaround, that I add a property with some validation to my XML template where the editor can add a slug:

<property name="section_id" type="text_line">
    <meta>
        <title lang="en">Section ID (for anchor jumps)</title>
        <info_text lang="en">Allowed characters are letters, digits, plus and minus signs.</info_text>
    </meta>
    <params>
        <param name="pattern" value="^[\w\+\-]*$"/>
    </params>
</property>

This value is used as id in the HTML element in the twig template.

Then I add an external link to the navigation, where I specify the complete URL together with the section ID.