hey people

I just wanted to share this with everyone, I dont know if this is the place to put this or if anyone even cares or has said this before, but ive found a really SIMPLE way of doing date ranges in views, its taken about 5 days of banging my head against a wall and trying everything else that people had surgested (nothing worked!) So wanted to post this just in case there are some others trying to do the same thing.

OK, so what I was looking for, was a way of creating a price range, so people could set their own max and min price and only get returned items within that range.

I tried all the PHP code others had brought up and I couldnt get it to work. Its a big problem as you have to expose the same view twice to have both a min and a max price and that cant be done.

So how I did this, a little work around!!!!!

When your creating a node (Or your visitors are creating one as in my case) get them to put the price in TWICE

So I now have two fields-both decimal text fields. One marked for me "max price" and the other "min price"

If your having visitors inputing the value, you can hide the labels and just lie to them and say please put this value in twice to make sure its correct. In the same way sites ask for your email twice.

You now have the value in two fields (Hopefully the value is the same!)

Now in views you set the operator of the min price to "Equal or above" and LOCK IT!!! Then do the same for the Max price- with "Equal or below" and lock that one to. Dont want people changing the operators!

Then....well thats it! You have a view that will give you all the results in that range. All the user does is come along and TYPE in their max and min price and hit the view button.

Really hope this helps someone, again apologies if this has been covered before. But I couldnt find it.

Oh and this would work for price, age, any numerical value really! Thanks!

Comments

lias’s picture

workaround, thanks for the tip!

czeky’s picture

What about to just add field to copy the value instead of pushing a user to fill this twice?

drupallogic’s picture

ok but I don't see any operator "Equal or below" ? for Views in Drupal 6 ?