Developer forum

Forum » Rapido » Help with handlebar loop

Help with handlebar loop

Martin Grønbekk Moen
Martin Grønbekk Moen
Reply

We have two variant groups (size and color), and by default they both show in the item list view.
Now we want to keep that on the item card, but on the item list we would only like to show one variant group (color).

How would we go ahead and do that with all the handlebar action going on in these rapido templates...


Replies

 
Karsten Thuen Dynamicweb Employee
Karsten Thuen
Reply

Hi Martin

I would like to emphasize that variants are very complex to work with. And I am quite sure this is not only the case in Dynamicweb. The reason is mostly because we have multidimensional data that we must manipulate to render the correct variantoptions.

I understand your case, and can see why that would be required. So, if I understand you right, you want each color variant to be shown as independent products in the list. On each product, in the list, you will then be able to chose the size. Then, if you decide to go to the product page, you should have the posibility to change both size and color. 

I think we support this setup, but it is a little advaced. I have asked one of our experts regarding this. The answer is that, you should use PIM, and then then chose "Show in product list" on one product in each color. And then everything should work smoothly.

We are working hard to re-write the variants javascript engine for the frontend (Rapido). And, although, it will still be a little complex to understand, it should be much better and easier to hook into. 

 

Best regards
Karsten Thuen

 
Martin Grønbekk Moen
Martin Grønbekk Moen
Reply

Hi!

No, I dont want all color variants to be shown as separate products, they should be listed as it is now.
The only thing I want is to not list all variant groups (see screenshot).
In this example we only want to show "Color" and it should only be links to the item card, we are not going to enbale buying from the list, and so we do not need both variant groups.

We just need to know how to show only one group using the new templating system.

 
Karsten Thuen Dynamicweb Employee
Karsten Thuen
Reply

Hi again

Ok, that is a different case. And I hope I understand it better now. Unfortunately I do not see any screenshot? 

This may guide you on how to implement: Start by going to the Rapido template design folder and find eCom/ProductList/ProductListFeed.cshtml Then do as follows:

  • Add a new List variable to the "Product" object and call it "ColorVariants" like this: public List<ColorVariant> ColorVariants { get; set; } 
  • Scroll up, to just below the Variant object, and add a new object named "ColorVariant"
  • Add thee string variable diffinitions to it and name them: id, name, colorcode
  • Scroll down to the area where we add data to the existing variants object
  • If the colors are always in the first variants group, you could make a condition for it here, and then fill the ColorVariants list with options, only from the first group.
  • Make the same implementations as above in eCom/Product/ProductFeed.cshtml
  • Go to the eCom/Product/ProductsRender.cshtml template and create the script template for the new ColorVariants. It should be simple enough if you look at how the full variants template are made.

I hope it all makes sense. There is a lot more documentation on how to delvelop this at:

Designing JSON feeds:
https://doc.dynamicweb.com/rapido/development/development/rapido-javascript-ajax#sideNavTitle1-1-3

Using Handlebars.js
https://doc.dynamicweb.com/rapido/development/development/rapido-javascript-ajax#sideNavTitle1-1-1

 

Best regards
Karsten Thuen

 

You must be logged in to post in the forum