Developer forum

Forum » CMS - Standard features » Link to products page with filter in different languages

Link to products page with filter in different languages

Justin Sjouw Dynamicweb Employee
Justin Sjouw
Reply

Hi There,

Our customer wants to have 4 links on their homepage that will link to the product page with a predefined filter.

I cannot get this to work for multiple languages. If I define the link /products?Productline=%5BMasterline%5D I get a 404 because the "english" part is missing from the URL.

Ofcourse if I hard code the link to /english/products?Productline=%5BMasterline%5D the link works but always directs me to the english page, even if I am on a different langiuage version of the homepage...

So how would I be able to define a "language independent" link?

Thanks,

Justin


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Using Default.aspx?ID=123&restofparms=somevalues instead of full urls (which is never recommended). Of course then the pageid has to be different from language to language.  Could be a setting if you are using a custom item type. Dynamicweb will rename the link automatically to its friendly version if in an a-tag using href attribute.

If you are making the links in the template, you can do like this:

Get the productlist page id in Swift from a razor template: GetPageIdByNavigationTag("Shop")

GetPageIdByNavigationTag is a method on the razor template base class.

In code you can do like this:

Url = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Shop") + "&GroupID=" + string.Join(",", groupIds).Trim(),

Or add whatever parameters you want.

Votes for this answer: 1
 
Justin Sjouw Dynamicweb Employee
Justin Sjouw
Reply

Thanks, that works, ofcourse I am very lazy so I was hoping for a way to set it once on the master, and use the language automatically  :-)

One thing that is a bit confusing for the content editor is the UI shows the link is invalid:

 

You must be logged in to post in the forum