Search code examples
freemarkermagnolia

How do I redirect to a new page in a FreeMarker template?


I'm using a custom Magnolia forms module (built internally at my company). When the user successfully submits the form, I want to redirect the user to a success page.

This could be done in the module itself. However, if the user does not successfully submit the form (e.g. missing required fields), I need to display error messaging.

For this reason, I need to use FreeMarker to implement the redirect.

How do I redirect to a new page in a FreeMarker template?


Solution

  • Use the send redirect method. For example:

    ${ctx.response.sendRedirect("http://google.com")!}
    

    References