Closed (fixed)
Project:
Views (for Drupal 7)
Version:
5.x-1.0
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
2 Aug 2007 at 09:40 UTC
Updated:
28 Aug 2010 at 05:54 UTC
Hi guys,
Help me out please. How can I setup views filters to take params from the URL?
I'm stuck, please help
Comments
Comment #1
yched commented"filters taking params from the URL" = Views Arguments :-)
If you haven't already, you should start by digging there
Comment #2
mixey commentedI'm there, but I'm walking around and around, can't get main idea how to do that :(
how can I filter nodes by CCK field price where price is in range of 100 and 150 (those number I'll pass throw the url or with $_GET method from the search form)
I could not understand how to use Argument handling code for that. could you please help me with step by steps instructions or with screenshot?
And thanks for your time
Comment #3
mixey commentedBy now I came up with the following working code:
but it's just sorting...
Who knows how to make filter code work?
this one generates sql errors :(
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '> '105') AND (node.type IN ('furniture_item')) )' at line 1 query: SELECT count(node.nid) FROM node node LEFT JOIN content_type_furniture_item node_data_field_price ON node.vid = node_data_field_price.vid INNER JOIN users users ON node.uid = users.uid LEFT JOIN i18n_node i18n ON node.nid = i18n.nid WHERE (i18n.language ='ru' OR i18n.language ='' OR i18n.language IS NULL) AND ( (.field_price_value > '105') AND (node.type IN ('furniture_item')) ) in c:\program files\easyphp1-8\www\furniture\includes\database.mysql.inc on line 172.
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '> '105') AND (node.type IN ('furniture_item')) ) LIMIT 0, 10' query: SELECT node.nid, node.title AS node_title, node.changed AS node_changed, node_data_field_price.field_price_value AS node_data_field_price_field_price_value, users.name AS users_name, users.uid AS users_uid FROM node node LEFT JOIN content_type_furniture_item node_data_field_price ON node.vid = node_data_field_price.vid INNER JOIN users users ON node.uid = users.uid LEFT JOIN i18n_node i18n ON node.nid = i18n.nid WHERE (i18n.language ='ru' OR i18n.language ='' OR i18n.language IS NULL) AND ( (.field_price_value > '105') AND (node.type IN ('furniture_item')) ) LIMIT 0, 10 in c:\program files\easyphp1-8\www\furniture\includes\database.mysql.inc on line 172.
Comment #4
TKS commentedmixie -
OK, I *think* I understand what you're trying to do. (yched is right -- if all you wanted to do was pass along a value and find nodes where the value EQUALED 100, then a simple argument will do it. But when you want to do a range, some funky argument handling code is required. At least for now, that is -- I seem to recall a post that said other operators are in the works for Views in the near future....)
I muddled through a similar problem -- see http://drupal.org/node/150248 -- so let's see if the code below will do what you want:
This assumes that -- based on the example you gave -- 100 would be the first variable passed, and 150 would be the second. IE: http://www.yoursitename.com/viewpath/100/150. (It also assumes that your use of CCK isn't too different from mine, that i18n or other modules aren't adding wrinkles, and that I haven't munged this entirely!!!)
If there are other arguments before those, you'd need to change the values for $lowend and $highend to $args[2] or $args[37] or whatever.
I won't pretend to fully understand the code above -- I basically experimented with what quicksketch posted at http://drupal.org/node/70145#comment-204051 to get working code for my site, and am now just swapping your variables into what worked for me. But if it works for you, declare victory, and go back and figure out *why* it works later! :)
Please post back and let folks know if this does the trick. Good luck.
TKS
Comment #5
mixey commentedIt didn't work for me :( but good news are that it doesn't generate sql errors anymore.
but id does nothing :(
there is drupal_set_message("begin"); for testing purposes and it doesn't work too.
I'll try to play with another drupal installation, without i18n. For the CCK field price, I'm using Decimal field type.
Any suggestions?
Comment #6
mixey commentedAll the code above I'm pasting in to the Argument handling code area.
I hope it's right
Comment #7
mixey commentedwith clean drupal installation plus Views and CCK, I got same result
Comment #8
mixey commentedfinally got the solution http://drupal.org/node/164471
Comment #9
moshe weitzman commentedComment #10
(not verified) commentedComment #11
summit commentedMikey,
Could you post your solution code?
Thanks in advance,
greetings,
Martijn
Comment #12
KentBye commented@Martijnhaan: Mikey did post his solution & explanation here: http://drupal.org/node/164471
Comment #13
summit commentedHi,
I am not able to follow this solution of Mikey in my situation..
I have 3 filters.
- The first is Node: Published
- The second is Node: Distinct
- The third is the Taxonomy: Terms for [my vocabulary]
The third is the one I would like to be able to use the arguments on.
I tried the following argument handling code:
But then I get the following errors...
Can somebody help please to get the filter working on taxonomy terms, with depth of 3?
Thanks a lot in advance!
greetings,
Martijn
Comment #14
gopi2msg commentedfriends I am new to writing code in drupal, can i know where to paste this code and how want to be tested
Comment #15
dawehnerThis is drupal 5, please keep it there.
Comment #16
shaina2231 commentedI need to pass dynamic CCK field values to Filters In contains Query I dont know how to do plz help
Comment #17
esmerel commentedThis issue has been closed; if you have a new problem, or a question on another version, open a new issue.