4 replies [Last post]
benko's picture
Offline
Joined: 01/14/2009
Juice: 66
Was this information Helpful?

Hey Guys,

I have enabled the product grid view but when I do this the 'Order' links disappear. Ideally id still like to be able to order by name/price in the grid.

Is this possible?

Apologies if this has been covered before, had no luck searching the forum.

Cheers

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Order Links in Product Grid View

Hey benko, unfortunately it's not possible, because the catalog is using a feature of the Drupal API called "table sorting" to get the default product list to be sortable. It automatically makes the header clickable and adds some sorting information to the database queries based on the query string that ends up in the URL. I don't even think this is possible in Views atm, either.

stephthegeek's picture
Offline
Theminator
Joined: 10/20/2007
Juice: 575
Ryan wrote:I don't even
Ryan wrote:

I don't even think this is possible in Views atm, either.

Nope, but it's a frequent feature request and I believe he's aiming to have sort links for grid/list views in the future.

In the meantime, a manual workaround is to create multiple displays with different sorts and link them in the view header.

Gorgeous original Drupal themes (and Ubercart themes!) ~ Psst: more Ubercart themes on our new site

benko's picture
Offline
Joined: 01/14/2009
Juice: 66
Ok! I have figured out a way

Ok!

I have figured out a way to do this quite effectively, its a little hacky but it does the job!

If you alter the theme_uc_catalog_product_grid function (unfortunately I still can't override this http://www.ubercart.org/forum/support/8593/theme_function_overriding_hel...) its possible to add a new tr at the top for sort elements.

I used php to find the current $_GET['q'] and append the sort variables on there as required (?sort=asc&order=Price etc).

Its hardcoded but it works exactly as required Smiling

Cheers

LoveGolf's picture
Offline
Joined: 10/16/2008
Juice: 106
Try this

There is a way to do this with views ... it's just not the cleanest.

Use views and make the initial grid view.

Give the view a page url of products/view/

Under Page/Menu settings check the box to give the view a menu item but also check the tab button as well.

Right below this box is a box where you can check making it the default tab, do this and give it the name "By Name" or "Sorted ABC" ...

Then, scroll down to sort option and order by node title ascending. Save view.

Now, clone the view you just made.

Change the name. Also, change the url to products/view/price

Go down to the menu tab settings and uncheck the box to make it appear as default tab but keep the other 2 selected. Give it a menu title like " By Price".

Lastly, go down to the sort options and sort by price desc or asc ... whichever you prefer. Save the view and go to the url of the first view you created and you should see a tab giving the option to sort by price.