Developer forum

Forum » CMS - Standard features » Localized links for content

Localized links for content

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Guys,

I have a situation that I have not encountered before but it totally makes sense from my customer's perspective.

The customer has a bunch of  Language layers (10) planning to add more. In most cases, these language layers are using the content from the master website with a few exceptions, 

The request is that any link added in the content (in the richtext editor) should be localized to the equivalent of the language area of the visitor.

Meaning that, if they add a link like /en-us/somepage (which actually means /Default.aspx?ID=12) in the masterpage, visitors that are accessing the same page in , let's say, german language layer, should see the link as /de-de/somepage (which actually means /Default.aspx?ID=35). I cannot rely on having the same page names and replacing the prefix according to the language layer.

I have scratched my head and I see just a few options:

1. Use a custom URL provider that will translate the ID of the page before trendering the friendly URL

2. Use some notification on before page load (or something similar)

Not sure if these 2 options mean the same thing :)

Any other idea about how to best implement this without affecting performance a lot?

Thanks,

Adrian


Replies

 
Nicolai Pedersen
Reply

Hi Adrian

I do not understand what you want to do.

But on a page, you can create a shortcut - and if you do not mark it as redirect, the content from the page linked will be rendered on the URL of the page that links to it. So that sounds like what you need in some form or another.

BR Nicolai

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi NIcolai,

I was worried it will be unclear.

The issue is related to links added in the Richtext editor in a paragraph content.

When you add a link as a reference to an existing page, the link is stored in the content field as it was initially added.

They want to render the link differently based on the language layer that you are in.
Assuming this content structure:

  • EN (master)
    • Homepage
    • About US
  • DE (language layer)
    • Homepage
    • About US

If they add a link in the homepage, to the English version of the About US page, they want this behavior:

When you access en/homepage, the link will be rendered en/about-us but when you access de/homepage, the link should be rendered as de/about-us

And all this, without editing the content of de/Homepage.

Does it make sense?

Adrian

 
Nicolai Pedersen
Reply
This post has been marked as an answer

If you link from one page to another page in the same language layer on a master, when that data is propagated to language versions, the links are updated to link to the simialar page on that language version and no longer the master.

If that does not happen, it might be related to bad data,.

BR Nicolai

Votes for this answer: 1
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

That's awesome. I was not aware of this. Now it makes a lot of sense.

Thank you for confirming this.

I will give it a try.

Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

I tried your suggestion but something is not right in my setup and I don't understand what.

I have this page: https://development-dynamicweb.biolegend.com/en-us/biomarkers-and-immunoassays/multiplex-kits

The first link in the content is set on the master layer on the paragraph and it is set to go to https://development-dynamicweb.biolegend.com/en-us/advanced-search (/Default.aspx?ID=5198)

When I set the paragraph on the master layer, the localized paragraphs on the other layers seem to be inactive. I have activated the corresponding paragraph on the language layers, but the link is the same in all language area. It does not get localized. The above link, in the French language layer, is supposed to go to /Default.aspx?ID=10244 (the french version of the advanced search page). At least that should happen if I understood correctly your explanation.

What setting am I missing?

Adrian

 
Nicolai Pedersen
Reply

You are missing no settings.

Just checked it out. Could be a bug... Eventhough the code does not seem to have changed in 3 years! So it could be bad data.

Anyways - we will try to reproduce it and get back.

BR Nicolai

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Thanks Nicolai,

I am not sure what else to check. The paragraph template is the same we have used for nearly 2 years.

And the data is fresh. I just added it.

Looking forward to your findings.

Thanks,

Adrian

 

 
Oleg Rodionov Dynamicweb Employee
Oleg Rodionov
Reply

Hi all

Adrian, I've tested your solution: 

1. Diactivation of page and paragraphs in language version follows to current settings of your solution, so it's feature (attachment):

2. I see the bug regarding to link is reproduced on your site used old admin version (8.9.1.13) but isn't on my environment based on last DW8 (8.9.2.7) as well as on DW93 recently released, so the bug was probably fixed on one of versions after yours. You have to upgrade the solution, first of all, not to have the bug.

My suggestion - research and follow to DW manual not to have an issue like point 1 above :)

http://doc.dynamicweb.com/documentation-8/introduction

http://doc.dynamicweb.com/documentation-9/introduction

BR, Oleg QA 

2017-09-06_1609.png
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Oleg,

THank you for your feedback.

The solution was previously configured. I just started working on it a few weeks ago. I have avoided changing any settings because I don;t know their implications yet. 

But now I know were to look when it comes to it.

I will recommend an upgrade of the solution to fix the link localization.

Thanks a lot.

Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

We have upgraded to 8.9.2.10.

I have tried again and it does not seem to work.

The page in question is this: https://development-dynamicweb.biolegend.com/de-de/biomarkers-and-immunoassays/multiplex-kits

The first link  LEGENDplex™ sis set to go to the advanced page in the master language (https://development-dynamicweb.biolegend.com/en-us/advanced-search). If I switch to the German language, my understanding is that it is supposed to be directed to the DE version of the same page. Meaning that the link should be https://development-dynamicweb.biolegend.com/de-de/advanced-search

Is my understanding wrong or am I doing something wrong on the setting?

Thanks,

Adrian

 
Nicolai Pedersen
Reply

This is an item texteditor, and I do not think those are covered in updating links...

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Thank you for your answer.

This means I have completely missunderstood the entire conversation above.

That being said, what would be the best approach to accomplish what I have described? A URL Provider? Other solution?

Thanks,

Adrian

 
Nicolai Pedersen
Reply

No you havent. It just does not work for RTE fields in items...

Only option is to update the links manually.

 
Oleg Rodionov Dynamicweb Employee
Oleg Rodionov
Reply

Hi all,

Adrian, I've checked your solution with new language created (see attached pic, Test area not active now). I can now see that link have you mentioned above points to correct page wihin the site i.e. the feature regarding localization works correctly with the admin as I wrote above. So, if the existing languages are exact same as master (not extra edited after creation) then you can try to re-create the languages using the master to have valid links.

PS. please, delete the 'Test' area by yourself after confirming.

BR, Oleg QA

2017-10-03_1956.png
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Oleg,

I do not see a different behavior than the one I was experience before.

If I define a link in RTE, to a page from the same layer, the link is not localized when I switch to a different language layer.

Meaning that https://development-dynamicweb.biolegend.com/en-us/advanced-search is not rendered as https://development-dynamicweb.biolegend.com/de-de/advanced-search when I go to the German language layer.

From what I understand from Nicolai's answer, the behavior requested by our customer is not possible for links added in the RTE.

However, my question still remains:

How do I accomplish this with custom code?

Thanks,

Adrian

 
Oleg Rodionov Dynamicweb Employee
Oleg Rodionov
Reply

Hi,

As far as I know the localization is apliied during new language creating only (it didn't work correctly on old releases as I commented above) but not for existing one, so I've suggested appropriate solution above. If it's not fit for you then all existing links in languages should be adjusted manually or using an extra custom code should be developed, probably. Perhaps, Nicolai or somebody else could comment the development better.

BR, Oleg QA   

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi guys,

I'm working with Adrian on this and try to come up with a custom solution to handle this. Here's what I think we can do:

Use a notification subscriber that runs just before Dynamicweb does its output replacement. In that subscriber do something like this:

  1. Get hold of the HTML
  2. Detect if you’re in the right page type (not the master)
  3. Using regexes find all links in the format Default.aspx?ID=NNN
  4. Using a cached table of ID maps, find the ID in the master site and find its corresponding ID in the language specific one
  5. Rewrite the links that require updating

Then after that Dynamicweb's replacement will kick in and take your Default.aspx?ID=LanguageSpecificID and convert it into a friendly URL.

Would this work? It seems that Page.AfterOutput runs before OutReplacer.Replace, so it looks like a good candidate.

Can someone confirm this is a workable approach or not, and whether there are better alternatives? We don't want to go down a rabbit hole if we don't have to ;-)

Imar

 

You must be logged in to post in the forum