Question: Is there a way for a node to automatically redirect to another category page?
Why: Our community is divided out in to solutions and under each solution category are product sub-categories. Our marketing team, in their great wisdom, has decided some products live under two different solutions.
Our menu is dynamically generated so I have a product sub-category under one of the two solutions. I need to create a node under the other solution that will show up in the menu just like any other, but when clicked, will redirect to the real product sub-category.
Do you have any ideas on how to do that? Thanks in advance.
Solved! Go to Solution.
You can only redirect url using "setRedirectUrl" method of "http.response" to the different category by checking the node.id of the category and redirect it to the the page you want in your community.
Like e.g:- In Lithium community if you want to redirect "Support Center" category to "Developer Network" category your code will be like below:
<#if coreNode.id == "supportcenter"> ${http.response.setRedirectUrl('/t5/Developer-Network/ct-p/Developer')} </#if>
http.response.setRedirectUrl("redirect_url") - this sets the URL to which the browser will be redirected. This method can be used only within the "page initialization script" in studio > Advanced.
Thanks I'll look at that.
@Parshant where do you put this code on the node to be redirected?
@kgroneman, You need to add this code in Studio > Advanced > Page Initialization.
Here is the link for its documentation.
You want to keep the page script as light as possible the odd one or two should be fine but as you need more a better way is to just get support to add a redirect for you, can be done in a couple of hours normally, day or two max.
Stephen
Checkout some of the stuff i've built using the platform:
Community l Ideation l Blog l Product Hubs l Check & Report l Service Status
My latest Ideas: Vanity URL Manager l @mention Roles l LSW Password Policy
I asked Lithium support about best practices for redirects like this. Here's what they said:
If you want to be able to edit and change the redirect at any time then the page initialization script will allow you to do this. The page initialization script will run before any page in the community is loaded, including admin and studio pages. This means that if the redirect is not set correctly in the page initialization script, it could break other pages, prevent you from being able to log in, and will need to be reverted by Lithium.
Most users choose to set up redirects in the backend through a configuration Lithium does. This option has a much lower risk of causing unexpected behaviour. Support can make changes to the redirect quickly if you provide approval to make the change on production when you first open a case. Changes to redirects do not require waiting for a maintenance window, so they can be added and changed quickly.
I would recommend going through Lithium support to create and manage redirects, but if you need to be able to manage the redirect yourself then the page initialization script will work.
This method is also good to fixing any 404s you have across your site.
Stephen
Checkout some of the stuff i've built using the platform:
Community l Ideation l Blog l Product Hubs l Check & Report l Service Status
My latest Ideas: Vanity URL Manager l @mention Roles l LSW Password Policy
Welcome to the Technology board!
Curious about our platform? Looking to connect on social technology? You've come to the right place!