Developer forum

Forum » Templates » Navigating Variants

Navigating Variants

Afi
Reply

Hi,

1) Is it possible to navigate to a SEO compliant URL when navigating variants?
E.g. ~/Product-Name/Variant-Name OR just /Product-Name assuming Customer had changed the name for each variant.

2) Also, when navigating variants, is it possible to implement functionalities that is similar to nike.com and adidas.com? For https://nike.com, when navigating variants, images and url change dynamically. For http://adidas.com, is it possible to see the variants when hovering a product in the product list.

 

Regards,
Afi

 

adidas.png nike.png

Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Afi,

 

1) You can do that in your Razor templates. When in the Product detail template you can confirm which variant combination is submited in the querystring (VariantID), and based on that render that variant's information instead of the product. That ensures your template reacts to the Variant.
Another option is to apply item 2 (below) and then when the page loads, check if there's a variantID in the querystring and trigger the js function that manages the images (+ stock + price + ...) to be changed.

 

2) The URL changing can be achived with some javascript by using history.pushState. This allows you to update your URL (to what would have been in item 1 above). The rest is pure javascript. You might need to either populate some javascript objects with all of the variant combinations data you want to change OR use some ajax calls to get that information.

 

Best Regards,

Nuno Aguiar

 

You must be logged in to post in the forum