Marco in URL Redirection

Suneel Jhangiani asked on October 20, 2018 15:46

I'm working on a site using the portal engine, and have create a 'User Profile' page with a path/pattern of /User/{UserID}. This works fine for pulling up the page with the relevant user details. However, I have now created sub-pages such as 'General', 'Images', and 'Videos'.

What I'd like to do is redirect the '/User/{UserID}' to the first child ('General') sub-page. However, if I select first child then it tries to redirect to 'User/Profile/General'. I have also tried specifying '/User/{UserID}/General' in the URL Redirection, which redirects to the same string (ie. UserID is not translated) and if I try '/User/{?UserID?}/General' then I get redirected to '/User/General'

Correct Answer

Brenden Kehren answered on October 20, 2018 19:41

Where are you navigating to it from? You may have to generate that URL manually and dynamically populate the username.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on October 20, 2018 16:10

In your User page aliases you need to add those aliases as well like so.

/user/{user}/general

Or if you have an actual General page below User, then on the General page you need to add the aliaa:

/user/{user}/general

0 votesVote for this answer Mark as a Correct answer

Suneel Jhangiani answered on October 20, 2018 18:27

The path or pattern for the 'General' page is set to '/User/{UserID}/General'. It works fine when I manually enter the URL, the bit that doesn't work is visiting '/User/{UserID}' and getting redirected to '/User/{UserID}/General'.

I can't set it to use first child as that shows the url as 'User/Profile/General'

If I try with URL Redirection as '/User/{UserID}/General' then I get that as the URL (ie. UserID is not lookedup)

If I try setting URL Redirection as '/User/{%UserID%}/General' it seems as though it won't resolve the {%UserID%} macro as I get '/User/General'

To clarify in essence what I want is to have '/User/{userID}' redirect to '/User/{userID}/General'

0 votesVote for this answer Mark as a Correct answer

Suneel Jhangiani answered on October 20, 2018 19:46

I did figure that, but I was actually hoping to switch it to '/User/{UserNickname}' to make it easy for users to get.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on October 20, 2018 19:49

You have to encode the user nickname because it has spaces and special characters in it. Plus it's not unique so I wouldn't recommend using that field.

0 votesVote for this answer Mark as a Correct answer

Suneel Jhangiani answered on October 22, 2018 10:59

Brenden,

Thanks for the advice on the User nickname field, however, this is actually based on a simplified model. The model I am using uses fields from a custom module and is a bit more complex although the equivalent 'User nickname' field is unique and only made up of characters that would not need encoding.

I'll mark one of your answers correct as I have had another look at the structure and feel I was doing things a bit wrong - basically the /User/{UserID} page should be the /User/{UserID}/General page. This eliminates the need to redirect down to the next level and all the links from the general page can point down a level.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.