Disabling routes


(Alex S) #1

Hey there,

im quite new to Neos and im trying to create a simple custom document node. Lets call it news. It works fine for now, but in the future im trying to show the pure data in a modal on a page called ‘/news,’ so there is no need for a detail view. Is there a way to disable the generated path segment, so the route ‘news/news-article.html’ is not accessible in the frontend?

Best regards
Alex


(Bastian Heist) #2

Hi Alex,
I’m afraid I don’t quite understand what your goal is, so I’m not sure what to recommend. Can you explain your use case a little better? Do you want to use the “news detail” simply as a source of structured data, which you load in a modal? In that case, simply not linking to the detail view might be enough, or is there a particular reason why you’d want to forbid users from accessing that detail data directly?


(Alex S) #3

Hi Bastian,
thanks for the quick reply. Yes, I want to use the “news detail” as a source of data without creating a template for the detail view. Indeed, not linking to the detail view is enough. But in case some might land on the detail view by accident, I was just curious if there is a clean way to restrict the access in the frontend out of the box.


(Bastian Heist) #4

Mh, in that case I’d simply create a Fusion prototype for that “news detail” document nodetype that doesn’t render anything. Basically this:

prototype(Your.Site:NewsDetail) < prototype(Neos.Fusion:Value) {
    value = ''
}

or, if you don’t want empty pages (e.g. for SEO reasons), you could also do a redirect using Neos.Fusion:Http.Message (written from the top of my head, not sure if it works 100% this way):

prototype(Your.Site:NewsDetail) < prototype(Neos.Fusion:Http.Message) {
    httpResponseHead {
        statusCode = '301'
        headers {
            Location = Neos.Neos:NodeUri {
                node = ${q(site).find('[instanceof Your.Site:NewsOverview]').get(0)}
                absolute = TRUE
            }
        }
    }
}