Motivation

:
In general, you need a exposed filter, which e.g. has a "contains" operator an operates like a search, but on several fields at the same time, not just one. So e.g. look in the user->name and user->email field to match this filter, or esp. with CCK implementations, it can become very useful, if implemented generically.

Proposal: Phase 1

:

  • new global filter: Compounded
  • you can select 2 fields which are concatenated using a space
  • importantthe direct field-alias is used by the query, not what the filter-handler is returning in render. This will need documentation and a hint for the end-user
  • the sql backend, concats every field selected in the SQL query, giving it a alias..which can then be used for the filter

Proposal: Phase 2

:

  • You can select any number of fields

Comments

eugenmayer’s picture

Title: "Compounded Filter" - create filter for sveral fields which are concatenated » "Compounded Filter" - create filter for filtering several concatenated fields which
eugenmayer’s picture

we should rather not use CONCAT_WS, as its not ansi-sql. As suggested, we should use

CONCAT(field1, $seperator,field2,  $seperator, field3...)
dawehner’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Active » Needs review
StatusFileSize
new5.58 KB

The patch was developed against 7.x-3.x, there is nothing which can be changed here.

A backport should be actually much less code.

dawehner’s picture

StatusFileSize
new5.68 KB

This time with proper seperation of the spaces.

dawehner’s picture

StatusFileSize
new5.42 KB

Here is a version with a multi-select as ui.

eugenmayer’s picture

Kam glad to Test Run the d6 verslum when its available. Tanks for the work!

steffenr’s picture

Category: feature » bug
Status: Needs review » Active

Thanks for providing the patch - unfortunatly it causes in SQL error while using Field-API Fields. If you look in the SQL-Query the table names are missing for the fields. In my case i'm using domain_access - but this should not crash the query - non-filtered output is ok.

SELECT DISTINCT users.uid AS uid, users.name AS users_name, 'user' AS field_data_field_user_vorname_user_entity_type, 'user' AS field_data_field_user_name_user_entity_type
FROM 
{users} users
LEFT JOIN {domain_editor} domain_editor ON users.uid = domain_editor.uid
LEFT JOIN {domain} domain_domain_editor ON domain_editor.domain_id = domain_domain_editor.domain_id
LEFT JOIN {domain_access} domain_domain_editor__domain_access ON domain_domain_editor.domain_id = domain_domain_editor__domain_access.gid AND domain_domain_editor__domain_access.realm = 'domain_id'
WHERE (( (domain_domain_editor__domain_access.gid = '1') AND (domain_domain_editor__domain_access.realm = 'domain_id') ) AND(( (CONCAT(.field_user_vorname_value) LIKE 'Steffen'))))

SteffenR

dawehner’s picture

Category: bug » feature
Status: Active » Needs review
StatusFileSize
new5.76 KB

Hey that's not an already existing bug :)

Here is a small improvement to the patch, which simply requires to add the table to the query all the time.

steffenr’s picture

@dereine - thx for rerolling the patch - i tried it on my view and it worked like charme. It would be great if we could bring it into views core..

SteffenR

dawehner’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Needs review » Patch (to be ported)
StatusFileSize
new6.31 KB

Thanks for the testing!

Committed with some small improvements, see patch to 7.x-3.x

Now the patch can be backported to 6.x-3.x

eugenmayer’s picture

how can i test it for d6 to help you out?

derhasi’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Patch (to be ported) » Needs work

Sorry, Daniel, I have to reopen this issue for D7 again, as there is a problem with relationships, due to the $field->ensure_my_table(); part in pre_query(). It breaks the relationships, as $this->_pre_query(); is called before $this->_build('relationship'); in view::build().

One thought to fix this, could be moving ensure_my_table() to query(). I'll test this with SteffenR's help.

steffenr’s picture

StatusFileSize
new986 bytes

Like derhasi said, we retested the whole thing by putting ensure_my_table directly into the query() - function.
In my testings it worked fine - i hope it won't break any other "views - query - building - stuff" ..

Attached you find a patch that should apply to the latest views DEV ..

derhasi’s picture

Status: Needs work » Needs review

I tested it on the view that created the problem, and I've to say, it works with the additional patch of #13 (plus #10).

dawehner’s picture

Status: Needs review » Needs work
-    // Always add the table of the selected fields to be sure a table alias exists.

You asked for a review here is one. It would be cool to still have this comment

derhasi’s picture

Status: Needs work » Needs review
StatusFileSize
new1.05 KB

dereine, ok, there's the comment ;)

dawehner’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Needs review » Patch (to be ported)

Thanks! Now let's backport it. For other patches it might be helpful to create new issues, so it's less confusing.

eugenmayer’s picture

So its D6 time? Can i assist somehow?

dawehner’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new3.81 KB

Okay here is a patch for the port.

eugenmayer’s picture

will test it - awesome Daniel!

tommyk’s picture

I've only tested it on one view in D6, but it worked. Excellent functionality.

IWasBornToWin’s picture

Am I understanding I might be able to type data into one filter but include other fields to be searched upon? I'd really enjoy this. If so, is there a patch or module for Views 7.3?

eugenmayer’s picture

Well we ran into issues with one field, 5 fields worked out. What is specic to this field?
- its CCK multiple textfield
- the field configuration is configured to return the first field only
- those are telefon numbers ( as string)

The reason is, the field missed the alias in the concat, we debugged it down: http://pastie.org/6051975 on line 52
As you see, the field-table alias is broken, even the . is there.

Iam pretty suprised though that the field is missing in the FIELD part of the select statement. the field is shown, its neither exclude (well that would not even matter). Here is a screenshot of the field configuration: http://screencast.com/t/XILZ2ZxQD

Daniel, if you have time, just ping me, iam glad to help debugging

eugenmayer’s picture

Status: Needs review » Needs work

updating status

dawehner’s picture

+++ b/handlers/views_handler_filter_combine.incundefined
@@ -0,0 +1,79 @@
+//      $field->ensure_my_table();

"Awesome"

eugenmayer’s picture

StatusFileSize
new3.81 KB

Actually, awesomesouce!

I rerolled the patch, so be aware!

dawehner’s picture

+++ b/handlers/views_handler_filter_combine.incundefined
@@ -0,0 +1,79 @@
+      if (!empty($field->field_alias) && !empty($field->field_alias)) {

This line should really check for both table alias and field alias.

eugenmayer’s picture

could you reroll? Not sure which location you mean - ill test it

dawehner’s picture

I mean exactly that line. It should be more like if (!empty($field->table_alias) && !empty($field->field_alias)) {

mustanggb’s picture

Issue summary: View changes
Status: Needs work » Closed (won't fix)