Navigation to External - Parametrized

ICAP Brasil asked on January 10, 2018 13:56


Suppose I have a Kentico site which have several links (navigation) to another site, not in Kentico, totally different domain names. So I have created a bunch of pages in Kentico and have set the URL Redirection property (navigation tab) of these to the proper URL (on the another site). This is working fine.

Suppose I have 3 environments: DEV, UAT and PRO. I would like to have all these "external" links easilly set up to the proper counterpart (real names are not so well standardized as this example.):

  • links in dev.kentico-site points to dev.another-site.
  • links in uat.kentico-site points to uat.another-site.
  • links in pro.kentico-site points to pro.another-site.

My first bet was to set URL Redirection of all these external pages to something like "http://{%another-site}/proper-page.htm". And also, to have this "{%another-site}" macro (or global property) set up globally once per environment. This way I could easilly move pages from one env to another without changing anything.

Is this approach possible? If not, can you see another way to have the same flexibility? I'm (still) using Kentico 8.2.

Thankyou very much.

Correct Answer

Peter Mogilnitski answered on January 10, 2018 14:32

I think you pretty much answered yourself: URL redirection with a macro to point to an appropriate environment and site. For macro I would probably use custom settings, so the environment type is defined in custom settings and then use the following expression to get setting values inside macros: Settings.<settings key code name>, So redirection URL will look likehttp://{%Settings.environmentType%}

1 votesVote for this answer Unmark Correct answer

Recent Answers

Brenden Kehren answered on January 10, 2018 14:26

You could create a JavaScript listener that checks link clicks of outgoing links. If the specified click being clicked is in the dev environment prepend dev. to the URL.

A more complex way is to add a global event handle for the staging event of those specific class names. When they are staged, update the data being staged.

0 votesVote for this answer Mark as a Correct answer

ICAP Brasil answered on January 10, 2018 17:43

Brenden, I believe your solution will work, but seem to assign the responsibility to the wrong "person". IMHO, it should not be handled by javascript. Thankyou very much for your time, anyway.

Peter, I was not aware of custom settings. I may have studied more of Kentico internal before. I followed your directions and now it is working like a charm. Thank you very much.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on January 11, 2018 15:20

Reason behind my answer is it is a "set it and forget it". Whereas with settings they can be synchronized across from one environment to another and cause problems in the other environment. I like the settings setup but leaves too much room for someone who doesn't know to easily make a change and mess up the other environments.

0 votesVote for this answer Mark as a Correct answer

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