views: custom conditions using fields from multiple tables
hi, for a site specific view I'd need to implement a view which's query has a condition that spans multiple tables. It'll look something like: table1.field = 'value' OR table2.field = 'other value' Is this possible using D6/views2 ? Am I better off just using a custom query? thanks in advance for any pointers! regards, roman
This should be in the Support list. I believe using the "Relationship" stuff would allow this, but you may have to build a module to provide that information. In which case, doing your own query is probably faster. Nancy Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr. From: Roman Zimmermann
for a site specific view I'd need to implement a view which's query has a condition that spans multiple tables. It'll look something like: table1.field = 'value' OR table2.field = 'other value'
Is this possible using D6/views2 ? Am I better off just using a custom query?
I think this is a fair development question, since the answer is "you have to write code to do this". You can do variable query handlers in custom field handlers -- that's what I usually do -- but it does require writing code. Essentially, your query() method can be responsive to input or conditions in the rest of the View (including arguments.) Here's a snippet that (while out of context) will show you the basic approach. http://drupalbin.com/19138 If you think your logic can be abstracted and used in multiple places, a Views filter is a great option. If not, just a custom query is fine. On Thu, Jul 7, 2011 at 4:30 PM, Ms. Nancy Wichmann <nan_wich@bellsouth.net> wrote:
This should be in the Support list.
I believe using the "Relationship" stuff would allow this, but you may have to build a module to provide that information. In which case, doing your own query is probably faster.
Nancy
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
From: Roman Zimmermann for a site specific view I'd need to implement a view which's query has a condition that spans multiple tables. It'll look something like: table1.field = 'value' OR table2.field = 'other value'
Is this possible using D6/views2 ? Am I better off just using a custom query?
-- Ken Rickard agentrickard@gmail.com http://ken.therickards.com
Not *custom field handlers*, custom *filter* handlers. On Fri, Jul 8, 2011 at 1:24 PM, Ken Rickard <agentrickard@gmail.com> wrote:
I think this is a fair development question, since the answer is "you have to write code to do this".
You can do variable query handlers in custom field handlers -- that's what I usually do -- but it does require writing code.
Essentially, your query() method can be responsive to input or conditions in the rest of the View (including arguments.)
Here's a snippet that (while out of context) will show you the basic approach.
If you think your logic can be abstracted and used in multiple places, a Views filter is a great option. If not, just a custom query is fine.
On Thu, Jul 7, 2011 at 4:30 PM, Ms. Nancy Wichmann <nan_wich@bellsouth.net> wrote:
This should be in the Support list.
I believe using the "Relationship" stuff would allow this, but you may have to build a module to provide that information. In which case, doing your own query is probably faster.
Nancy
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
From: Roman Zimmermann for a site specific view I'd need to implement a view which's query has a condition that spans multiple tables. It'll look something like: table1.field = 'value' OR table2.field = 'other value'
Is this possible using D6/views2 ? Am I better off just using a custom query?
-- Ken Rickard agentrickard@gmail.com http://ken.therickards.com
-- Ken Rickard agentrickard@gmail.com http://ken.therickards.com
Ken Rickard wrote:
I think this is a fair development question, since the answer is "you have to write code to do this".
The question is "is this Drupal core development", yes, then it is on topic for this list, no, then use the support list cause it is off topic for this list. This list definition is related to Drupal core development and not about using Drupal to develop a site or modules for a site. So while you are correct in saying "this is a fair development question" you are wrong in believing that it is a fair question for this list. -- Earnie -- http://progw.com -- http://www.for-my-kids.com
I never thought of this as a core list. On Fri, Jul 8, 2011 at 2:31 PM, Earnie Boyd <earnie@users.sourceforge.net> wrote:
Ken Rickard wrote:
I think this is a fair development question, since the answer is "you have to write code to do this".
The question is "is this Drupal core development", yes, then it is on topic for this list, no, then use the support list cause it is off topic for this list. This list definition is related to Drupal core development and not about using Drupal to develop a site or modules for a site. So while you are correct in saying "this is a fair development question" you are wrong in believing that it is a fair question for this list.
-- Earnie -- http://progw.com -- http://www.for-my-kids.com
-- Ken Rickard agentrickard@gmail.com http://ken.therickards.com
Ken Rickard wrote:
I never thought of this as a core list.
You, me, a few others. See http://drupal.org/node/1163962 for an issue to resolve the description problem. -- Earnie -- http://progw.com -- http://www.for-my-kids.com
On 7/7/2011 11:14 AM, Roman Zimmermann wrote:
hi,
for a site specific view I'd need to implement a view which's query has a condition that spans multiple tables. It'll look something like: table1.field = 'value' OR table2.field = 'other value'
Is this possible using D6/views2 ? Am I better off just using a custom query?
thanks in advance for any pointers!
regards, roman
Use the views_or module.
participants (5)
-
Earl Miles -
Earnie Boyd -
Ken Rickard -
Ms. Nancy Wichmann -
Roman Zimmermann