Khoros Community

Esteemed Contributor
Esteemed Contributor

Can you do a category level redirect?

Jump to solution

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.

 

--
Community manager in the Micro Focus Community. My computer always used to beat me at chess, but it is no match for me now I changed the competition to kick boxing.
0 Kudos
7 Replies 7
Honored Contributor
Honored Contributor

Re: Can you do a category level redirect?

Jump to solution

@kgroneman,

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.

 

.......
Do you know we work with Kudos and Accepted Solution.
Reply
Loading...
Esteemed Contributor
Esteemed Contributor

Re: Can you do a category level redirect?

Jump to solution

Thanks I'll look at that.

--
Community manager in the Micro Focus Community. My computer always used to beat me at chess, but it is no match for me now I changed the competition to kick boxing.
0 Kudos
Reply
Loading...
Esteemed Contributor
Esteemed Contributor

Re: Can you do a category level redirect?

Jump to solution

@Parshant where do you put this code on the node to be redirected?  

--
Community manager in the Micro Focus Community. My computer always used to beat me at chess, but it is no match for me now I changed the competition to kick boxing.
0 Kudos
Reply
Loading...
Honored Contributor
Honored Contributor

Re: Can you do a category level redirect?

Jump to solution

@kgroneman, You need to add this code in Studio > Advanced > Page Initialization.

Here is the link for its documentation.

.......
Do you know we work with Kudos and Accepted Solution.
Reply
Loading...
Honored Contributor Honored Contributor
Honored Contributor

Re: Can you do a category level redirect?

Jump to solution

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



My latest Ideas: Vanity URL Manager l @mention Roles l  LSW Password Policy


Reply
Loading...
Esteemed Contributor
Esteemed Contributor

Re: Can you do a category level redirect?

Jump to solution

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.


 

--
Community manager in the Micro Focus Community. My computer always used to beat me at chess, but it is no match for me now I changed the competition to kick boxing.
Reply
Loading...
Honored Contributor Honored Contributor
Honored Contributor

Re: Can you do a category level redirect?

Jump to solution

This method is also good to fixing any 404s you have across your site. 

Stephen



My latest Ideas: Vanity URL Manager l @mention Roles l  LSW Password Policy


0 Kudos
Reply
Loading...