Welcome Guest, Not a member yet? Register   Sign In
Grid and list view
#1

[eluser]doubleplusgood[/eluser]
Hi there,

I have some pages that currently list products from the database in a grid view. But I'd like to add functionality with 2 icons to choose between a grid view and a list view, both with paging.

I was wondering if anyone had any advice on how to do this in CI? I'm not sure if I need to be loading different views somehow?

Thank you. Smile
#2

[eluser]gvillavizar[/eluser]
You can make it with a condition:

Code:
if($view == "list"):
// load list code
else:
// load grid code
endif;
#3

[eluser]danmontgomery[/eluser]
Assuming you'd want to keep the pagination consistent between the two (ie, if you switch views on page 5, you're still on page 5), the best approach to this is probably a javascript one. Maybe something like: http://designm.ag/tutorials/jquery-display-switch/
#4

[eluser]gvillavizar[/eluser]
[quote author="noctrum" date="1280340451"]Assuming you'd want to keep the pagination consistent between the two (ie, if you switch views on page 5, you're still on page 5), the best approach to this is probably a javascript one. Maybe something like: http://designm.ag/tutorials/jquery-display-switch/[/quote]

But if he do it that way, when he changes from page 1 to page 2 the javascript will be again on the default view and the user will have to change it again. Unless he stores the value in a cookie or db.

With the condition approach, I assume he already has the value stored somewhere, that way the user can be in any page, and simply by changing the value wherever he stored it, the user can swith and navigate back and forth and change the layout without hassle.




Theme © iAndrew 2016 - Forum software by © MyBB