Can you disable nested URLs in Silverstripe 4?

Silverstripe Version:


I am trying to convert an existing website (based on a different custom php framework) to Silverstripe 4. The site has lots of pages some 3 to 4 levels deep in sub-menus, but the URL for each page is not nested.

I would like to keep it this way however Silverstripe 4 seems to create nested URLs by default. I can’t find any mention in the docs, on this forum or anywhere at all mentioning nested URLs or whether or not its possible to disable the default nested URL setup in Silverstripe?

I note that the SiteConfig class no longer has the disable_nested_urls() function it had in previous versions.

Any guidance greatly appreciated.

The disable_nested_urls() method was deprecated in Silverstripe 4 in favour of a config setting.

In your app’s yml config files, try adding the following:

  nested_urls: false

Run a dev/build and hopefully it’ll do what you’re expecting.

As a general tip, if a function has been removed from the code in a version jump like this, the old code is usually annotated with a deprecation notice, so a search in the API docs (or the code itself) can be a good place to start for answers:

Thanks Tim, that did indeed solve my problem.

I did search the API docs as you suggest, however I was searching version 4.x since that’s the version I’m using, and “nested_urls” does not return any results on version 4.x. It never occurred to me to try version 3.x