Developer forum

Forum » Ecommerce - Standard features » Grid vs List view display switch in Swift

Grid vs List view display switch in Swift

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

What is the recommended approach for configuring a switch between Grid view and List view in Swift?

Is there anything close to standard or do I have to be creative?

Thank you,
Adrian


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

No recommended way.

You can use Notifications.Ecommerce.ProductCatalog.OnBeforeProductListRender and change the template insance on the args object to be either grid or list depending on your needs.

You might be able to create 2 different list pages in Swift using components and then hook into some of the JS events in Swift and switch between those 2 pages.

NP

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Understood.

I was afraid of this answer :)

I will probably go with 2 components for the lists and control their display with a cookie or session variable.

Will investigate further.

Thank you,

Adrian

 

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

I ended up creating a new Component paragraph with 2 component properties (one for Grid and one for List).

In the template, based on a cookie property, we switch between the 2 components.

It seems very close to standard and it does not require extensive backend development.

Maybe it worths considering this as a standard approach for Swift if you don't have another alternative.

Thank you,
Adrian

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Nope, not for Swift - old world :-).

 

You must be logged in to post in the forum