Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.9
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
7 Oct 2010 at 09:38 UTC
Updated:
27 Jan 2012 at 11:46 UTC
Hi,
I managed to get a view with some custom sql through the use of hook_views_query_alter(&$view, &$query).
I added some where clauses.
What I want to do now is get the value of a date field (exposed) and bring this into my custom sql.
(DATE_FORMAT(STR_TO_DATE(node_data_field_club.field_club_value2, '%Y-%m-%dT%T'), '%Y-%m-%d') >= '2010-10-06')
I want to change the '2010-10-06' to the exposed input (from a suer) for the date field.
Can you guys help me out?
Thanx!
Comments
Comment #1
dawehnerYou should better use hook_views_pre_execute. There you have exposed_input availible in the $view object and $filter->value.
So you have to go through $view->filter and set the value of the handler to what you want.
Comment #2
timlie commentedThanx, i'll try that and report my findings!
Comment #3
timlie commentedI'm struggling with this hook.
In the hook_views_query_alter(&$view, &$query) i could add a where clause (and remove the others) like this:
Is this also possible with this hook? Leave the SQL intact and just change the where clauses?
Thanx
Comment #4
Letharion commentedNeeds an expert opinion :)
Comment #5
Letharion commentedDereine is a busy person :)
This question is getting rather old, and the OP hasn't responded for quite a while. I'm going to close it due to activity. Please re-open as necessary.
Timlie, is this still relevant to you? If so, please re-open.
Can you achieve what you want if you use both hooks?
Comment #6
timlie commentedIs fixed :-)
Comment #8
jmolinas commentedhow do you fix it?
thanks