Developer forum

Forum » Templates » E-com: Change template on productlist based on customer selection in frontend

E-com: Change template on productlist based on customer selection in frontend

Peter Bille Larsen
Reply
 Hi DW.

We have designed an option on a product list, where the user (frontend) can click to change the apperance of the productlist.

ie. List-items
ie. Picture and information.

The apperance is so radical, that I might need another template for the product list.

How can I set some variable, which interacts with the template system after a user has selected a choice on the frontend?. Is there any way to do this without writing a custom module, and if so I need a custom module, how could it be done?

Thanks :-)
Peter

Replies

 
Vladimir
Reply
Hi Peter!
It can be implemented without custom module.
The best way to do two types of view - is switching the current CSS class(view-list <> view-block). Believe me, there are no limits on complexity for this decision.

Solution with a variable, is also posible- send in the request type of the view(myShop?viewtype=list), and in template, analyze it <!--Server: Request.viewtype-->. But this decision will not be as elegant as a first

Best regard,
vladimir

 
Peter Bille Larsen
Reply
 Hi Vladimir.

Thats just awesome.

When you say switching the CSS class, you mean by making a JS cookie?  or do you mean switching css within DW's template system?

thanks :-)
//Peter
 
Nicolai Høeg Pedersen
Reply
Hi Peter

If you add a viewtype parameter to the URL, inside your list template you can do something like this:
if(Server: Request.viewtype=list)
include(productlist.html)
endif

if(Server: Request.viewtype<>list)
include(mosaic.html)
endif


 
Peter Bille Larsen
Reply

Great.

thanks for the help guys.

//Peter
 
Peter Bille Larsen
Reply

Hi Nicolai

I am having some problems with the default value.

I cannot get this to work: (because the viewtype is not set on the default value when you enter the productlist)

if(Server: Request.viewtype<>list)
include(mosaic.html)
endif

I have also tried:
If[Not](Server:Request.viewtype<contains>list
But this does not work either.

How do you think I could make the default value?
 
Nicolai Høeg Pedersen
Reply
Try using If Defined on Server: Request.viewtype instead.

 

You must be logged in to post in the forum